<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions"
      xmlns:p="http://primefaces.org/ui"
      xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
      xmlns:jsf="http://xmlns.jcp.org/jsf"
      xmlns:pt="http://java.sun.com/jsf/passthrough"
      xmlns:cc="http://java.sun.com/jsf/composite"
      xmlns:o="http://omnifaces.org/ui"
      xmlns:of="http://omnifaces.org/functions">
    <h:head>
    </h:head>
    <h:body>
        <ui:composition template="/dataverse_template.xhtml">
            <ui:param name="pageTitle" value="#{DatasetPage.editMode == 'CREATE' ? bundle['dataset.pageTitle'] : DatasetPage.workingVersion.title} - #{DatasetPage.dataset.owner.name}"/>
            <ui:param name="dataverse" value="#{DatasetPage.dataset.owner}"/>
            <ui:param name="dataset" value="#{DatasetPage.dataset}"/>
            <ui:param name="version" value="#{DatasetPage.workingVersion}"/>
            <ui:param name="deaccessioned" value="#{version.deaccessioned}"/>
            <ui:param name="locked" value="#{DatasetPage.locked}"/>
            <ui:param name="anonymizedAccess" value="#{DatasetPage.anonymizedAccess}"/>
            <ui:param name="anonymizedAccessEnabled" value="#{DatasetPage.anonymizedAccessEnabled}"/>
            <ui:param name="canUpdateDataset" value="#{DatasetPage.canUpdateDataset()}"/>
            <ui:param name="canDownloadFiles" value="#{DatasetPage.canDownloadFiles()}"/>
            <ui:param name="canIssuePublishDatasetCommand" value="#{permissionsWrapper.canIssuePublishDatasetCommand(DatasetPage.dataset)}"/>
            <ui:param name="showPublishLink" value="#{version == DatasetPage.dataset.latestVersion 
                                                      and DatasetPage.dataset.latestVersion.versionState=='DRAFT'
                                                      and canIssuePublishDatasetCommand}"/>
            <ui:param name="versionHasTabular" value="#{DatasetPage.versionHasTabular}"/>
            <ui:param name="versionHasGlobus" value="#{DatasetPage.versionHasGlobus}"/>
            <ui:param name="tooLargeToDownload" value="#{DatasetPage.tooLargeToDownload}"/>
            <ui:param name="tooLargeToDownloadOriginal" value="#{DatasetPage.tooLargeToDownloadOriginal}"/>
            <ui:param name="tooLargeToDownloadArchival" value="#{DatasetPage.tooLargeToDownloadArchival}"/>
            <ui:param name="sizeOfDataset" value="#{DatasetPage.sizeOfDataset}"/>
            <ui:param name="sizeOfDatasetOrig" value="#{DatasetPage.sizeOfDatasetOrig}"/>
            <ui:param name="datasetExploreToolsSize" value="#{DatasetPage.datasetExploreTools.size()}"/>
            <ui:param name="sessionUserAuthenticated" value="#{DatasetPage.sessionUserAuthenticated}"/>
            <ui:param name="showComputeButton" value="#{DatasetPage.showComputeButton()}"/>
            <ui:param name="canSeeCurationStatus" value="#{DatasetPage.canSeeCurationStatus()}"/>
            <ui:param name="signpostingLinkHeader" value="#{DatasetPage.getSignpostingLinkHeader()}"/>
            <ui:param name="displayCitation" value="#{DatasetPage.displayCitation}"/>
            <ui:param name="description" value="#{DatasetPage.description}"/>
            <ui:param name="title" value="#{DatasetPage.title}"/>
            <ui:param name="datasetAuthors" value="#{DatasetPage.datasetAuthors}"/>
            <ui:param name="dataverseSiteUrl" value="#{DatasetPage.dataverseSiteUrl}"/>
            <ui:param name="thumbnailString" value="#{DatasetPage.thumbnailString}"/>
            <ui:param name="jsonLd" value="#{DatasetPage.jsonLd}"/>
            <ui:param name="croissant" value="#{DatasetPage.croissant}"/>
            <ui:param name="latestVersionInReview" value="#{DatasetPage.dataset.latestVersion.inReview}"/>
            <ui:param name="showSubmitForReviewLink" value="#{DatasetPage.editMode != 'CREATE' and version == DatasetPage.dataset.latestVersion
                                                              and !DatasetPage.datasetLockedInWorkflow
                                                              and DatasetPage.dataset.latestVersion.versionState=='DRAFT'
                                                              and canUpdateDataset
                                                              and !canIssuePublishDatasetCommand}"/>
            <ui:param name="showReturnToAuthorLink" value="#{DatasetPage.dataset.latestVersion.versionState=='DRAFT' and latestVersionInReview
                                                             and canIssuePublishDatasetCommand}"/>
            <ui:param name="showAccessDatasetButtonGroup" value="#{(canDownloadFiles or versionHasGlobus)
                                                                   and (!deaccessioned
                                                                   or (deaccessioned and canUpdateDataset))}"/>
            <!-- TO-DO FIX RSYNC LOGIC !fileMetadata.dataFile.filePackage or
                                                    fileMetadata.dataFile.filePackage and systemConfig.HTTPDownload -->
            <!-- NOTE removed fileAccessRequest logic in order to always display the file access btn -->
            <ui:param name="showAccessFileButtonGroup" value="#{!deaccessioned
                                                                or (deaccessioned
                                                                and permissionsWrapper.canIssueUpdateDatasetCommand(FilePage.fileMetadata.datasetVersion.dataset))}"/>
            <ui:param name="publishDataset" value="#{DatasetPage.publishDatasetPopup()}"/>
            <ui:param name="releaseDraft" value="#{DatasetPage.releaseDraftPopup()}"/>
            <ui:param name="releaseBoth" value="#{DatasetPage.publishBothPopup()}"/>
            <ui:param name="valid" value="#{DatasetPage.valid}"/>
            <ui:define name="meta_header">
                <ui:fragment rendered="#{!anonymizedAccess}">
                    <meta name="description" content="#{description}"/>
                </ui:fragment>
            </ui:define>
            <ui:define name="dc_meta_header">
                <ui:fragment rendered="#{!anonymizedAccess}">
                    <meta name="DC.identifier" content="#{DatasetPage.persistentId}"/>
                    <meta name="DC.type" content="Dataset"/>
                    <meta name="DC.title" content="#{title}"/>
                    <meta name="DC.date" content="#{version.publicationDateAsString}"/>
                    <meta name="DC.publisher" content="#{DatasetPage.publisher}" />
                    <meta name="DC.description" content="#{description}" />
                    <ui:repeat var="author" value="#{datasetAuthors}">
                        <meta name="DC.creator" content="#{author}"/>
                    </ui:repeat>
                    <ui:repeat var="subject" value="#{version.datasetSubjects}">
                        <meta name="DC.subject" content="#{subject}"/>
                    </ui:repeat>
                </ui:fragment>
            </ui:define>
                
            <ui:define name="jsonld_header">
                <ui:fragment rendered="#{!anonymizedAccess}">
                    <script type="application/ld+json">
                        <ui:fragment rendered="#{croissant == null}">
                            <h:outputText value="#{jsonLd}"/>
                        </ui:fragment>
                        <ui:fragment rendered="#{croissant != null}">
                            <h:outputText value="#{croissant}"/>
                        </ui:fragment>
                    </script>
                </ui:fragment>
            </ui:define>
            <ui:define name="og_header">
                <ui:fragment rendered="#{!anonymizedAccess}">
                    <meta property="og:title" content="#{title}" />
                    <meta property="og:type" content="article" />
                    <meta property="og:url" content="#{dataverseSiteUrl}/dataset.xhtml?persistentId=#{dataset.globalId}" />
                    <meta property="og:image" content="#{empty thumbnailString ? dataverseSiteUrl.concat(resource['images/dataverse-icon-1200.png']): dataverseSiteUrl.concat('/api/datasets/:persistentId/thumbnail?persistentId=').concat(DatasetPage.dataset.getGlobalId().asString())}" />
                    <meta property="og:site_name" content="#{DatasetPage.publisher}" />
                    <meta property="og:description" content="#{(description.length()>150 ? description.substring(0,147).concat('...') : description)}" />
                    <ui:repeat var="author" value="#{datasetAuthors}">
                        <meta property="article:author" content="#{author}" />
                    </ui:repeat>
                    <meta property="article:published_time" content="#{version.publicationDateAsString}" />
                </ui:fragment>
            </ui:define>
            <ui:define name="metadata">
                <f:metadata>
                  <f:viewParam name="id" value="#{DatasetPage.id}"/>
                  <o:viewParam name="ownerId" value="#{DatasetPage.ownerId}"/>
                  <f:viewParam name="version" value="#{DatasetPage.version}"/>
                  <f:viewParam name="versionId" value="#{DatasetPage.versionId}"/>
                  <f:viewParam name="persistentId" value="#{DatasetPage.persistentId}"/>
                  <f:viewParam name="showIngestSuccess" value="#{DatasetPage.showIngestSuccess}"/>
                  <f:viewParam name="fileSortField" value="#{DatasetPage.fileSortField}"/>
                  <f:viewParam name="fileSortOrder" value="#{DatasetPage.fileSortOrder}"/>
                  <o:viewParam name="tagPresort" value="#{DatasetPage.tagPresort}" default="true"/>
                  <o:viewParam name="folderPresort" value="#{DatasetPage.folderPresort}" default="true"/>
                  <f:viewParam name="q" value="#{DatasetPage.fileLabelSearchTerm}"/>
                  <f:viewParam name="fileTypeGroupFacet" value="#{DatasetPage.fileTypeFacet}"/>
                  <f:viewParam name="fileAccess" value="#{DatasetPage.fileAccessFacet}"/>
                  <f:viewParam name="fileTag" value="#{DatasetPage.fileTagsFacet}"/>
                  <o:viewParam name="selectTab" value="#{DatasetPage.selectTab}" default="dataFilesTab"/>
                  <f:viewAction action="#{dataverseSession.updateLocaleInViewRoot}"/>
                  <f:viewAction action="#{DatasetPage.init}" rendered="true"/>
                  <f:viewAction action="#{DatasetPage.viewActionInitBreadcrumbs()}"/> 
                  <f:viewAction action="#{EditDatafilesPage.initCreateMode(DatasetPage.editMode, DatasetPage.workingVersion, DatasetPage.uploadInProgress, DatasetPage.newFiles, DatasetPage.uploadedFiles, DatasetPage.selectedFiles)}"/>
                </f:metadata>
            </ui:define>
            <ui:define name="body">
                <!-- Add Signposting-->
                <c:if test="#{not empty DatasetPage.getSignpostingLinkHeader()}">
                    <f:event type="preRenderView" listener="#{facesContext.externalContext.response.setHeader('Link', DatasetPage.getSignpostingLinkHeader())}" />
                </c:if>
                <!-- End add Signposting-->
                <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                <o:importConstants type="edu.harvard.iq.dataverse.settings.FeatureFlags" />
                <ui:param name="versionNoteEnabled" value="#{FeatureFlags.VERSION_NOTE.enabled()}"/>
                
                <h:form id="datasetForm">
                    <h:inputHidden id="validateFilesOutcome" value="#{DatasetPage.validateFilesOutcome}" />
                    <h:inputHidden id="validTermsofAccess" value="#{DatasetPage.hasValidTermsOfAccess}" />

                    <!-- View infoMode -->
                    <!-- Top Button/Citation Blocks -->
                    <p:fragment id="topDatasetBlockFragment">
                        <div class="row" jsf:rendered="#{empty DatasetPage.editMode}">
                            <div class="col-xs-12">
                                <div id="datasetVersionBlock" class="row">
                                    <div id="title-block" class="col-xs-12 margin-bottom-half" jsf:rendered="#{!empty DatasetPage.displayTitle}">
                                        <h1 id="title">#{DatasetPage.displayTitle}</h1>
                                        <div id="title-label-block" class="margin-top-half">
                                            <!-- DATASET Publication Status -->
                                            <h:outputText value="#{bundle['dataset.versionUI.draft']}" styleClass="label label-primary" rendered="#{version.draft}"/>
                                            <h:outputText value="#{bundle['embargoed']}" styleClass="label label-primary" rendered="#{DatasetPage.isActivelyEmbargoed(version.fileMetadatas)}"/>
                                            <h:outputText value="#{bundle['retentionExpired']}" styleClass="label label-warning" rendered="#{DatasetPage.isRetentionExpired(version.fileMetadatas)}"/>
                                            <h:outputText value="#{bundle['dataset.versionUI.inReview']}" styleClass="label label-success" rendered="#{version.inReview}"/>
                                            <h:outputText value="#{bundle['dataset.versionUI.unpublished']}" styleClass="label label-warning" rendered="#{!DatasetPage.dataset.released}"/>
                                            <h:outputText value="#{bundle['dataset.versionUI.deaccessioned']}" styleClass="label label-danger" rendered="#{deaccessioned}"/>
                                            <h:outputText value="#{bundle['incomplete']}" styleClass="label label-danger" rendered="#{!valid}"/>
                                            <o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
                                            <h:outputText value="#{DatasetUtil:getLocaleCurationStatusLabel(version.currentCurationStatus)}" styleClass="label curation-status label-info" rendered="#{canSeeCurationStatus}"/>
                                            <!-- DATASET VERSION NUMBER -->
                                            <h:outputText styleClass="label label-default" rendered="#{version.released and !(version.draft or version.inReview or deaccessioned)}"
                                                          value="#{bundle['file.DatasetVersion']} #{version.versionNumber}.#{version.minorVersionNumber}"/>
                                            <h:outputText styleClass="label label-default" rendered="#{!version.released and !(version.draft or version.inReview or deaccessioned)}"
                                                          value="#{bundle['file.DatasetVersion']} #{version.versionState}"/>
                                        </div>
                                    </div>
                                </div>

                                <!-- START: NEW RESPONSIVE ABOVE FOLD BLOCK -->
                                <div id="datasetCitationActionSummaryBlock" class="row">
                                    <div class="col-xs-12 col-sm-12 col-md-8 col-lg-9">
                                        <!-- CITATION BLOCK -->
                                        <ui:fragment rendered="#{!empty displayCitation}">
                                            <ui:include src="dataset-citation.xhtml">
                                                <ui:param name="datasetPage" value="true"/>
                                                <ui:param name="anonymized" value="anonymizedAccess"/>
                                            </ui:include>
                                        </ui:fragment>
                                        <!-- END: CITATION BLOCK -->
                                    </div>

                                    <div class="col-xs-12 col-sm-12 col-md-4 col-lg-3 pull-right margin-bottom">
                                        <!-- ActionButtonBlock -->
                                        <div id="actionButtonBlock" jsf:rendered="#{!widgetWrapper.widgetView}">
                                            <!-- DOWNLOAD/ACCESS DATASET -->
                                            <div class="btn-group btn-group-justified" 
                                                 jsf:rendered="#{showAccessDatasetButtonGroup}">
                                                <div class="btn-group">
                                                    <button type="button" class="btn btn-primary btn-access-dataset dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                                        #{bundle['dataset.accessBtn']} <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu pull-right text-left" style="padding-left:1em; padding-right:1em;" >
                                                        <!-- DOWNLOAD -->
                                                        <ui:fragment rendered="#{canDownloadFiles}">
                                                            <ui:fragment rendered="#{!tooLargeToDownload}">
                                                                <li class="dropdown-header">#{bundle['dataset.accessBtn.header.download']} <span class="glyphicon glyphicon-download-alt"/></li>
                                                                <!-- NORMAL DOWNLOAD BUTTON (NO TABULAR FILES) -->
                                                                <li jsf:rendered="#{!  versionHasTabular}">
                                                                    <p:commandLink update="@form" actionListener="#{DatasetPage.startDownloadAllOriginal()}" styleClass="btn-download" 
                                                                                   oncomplete="showPopup(false);">
                                                                    #{bundle.download}
                                                                        <h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
                                                                            <f:param value="#{sizeOfDataset}" />
                                                                        </h:outputFormat>
                                                                        <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                                                                    </p:commandLink>
                                                                </li>

                                                                <!-- DOWNLOAD Options (TABULAR FILES PRESENT) -->
                                                                <ui:fragment rendered="#{  versionHasTabular}">
                                                                    <!-- DOWNLOAD ORIGINAL BUTTON (TABULAR FILES PRESENT) -->
                                                                    <li jsf:rendered="#{ sizeOfDatasetOrig != '0 B'  and !(tooLargeToDownloadOriginal) }">
                                                                        <p:commandLink update="@form" actionListener="#{DatasetPage.startDownloadAllOriginal()}" 
                                                                                       oncomplete="showPopup(false);"
                                                                                       styleClass="btn-download">
                                                                            #{bundle.downloadOriginal}
                                                                            <h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
                                                                                <f:param value="#{sizeOfDatasetOrig}" />
                                                                            </h:outputFormat>
                                                                            <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                                                                        </p:commandLink>
                                                                    </li>
                                                                    <!-- Original Format too big -->
                                                                    <ui:fragment rendered="#{tooLargeToDownloadOriginal}">                                                                                                                               
                                                                        <h:outputText value="#{bundle['dataset.accessBtn.original.too.big']}">                                           
                                                                        </h:outputText>                                                            
                                                                    </ui:fragment>
                                                                    <!-- DOWNLOAD ARCHIVAL FILES (TABULAR FILES PRESENT) -->
                                                                    <li jsf:rendered="#{!tooLargeToDownloadArchival}">
                                                                        <p:commandLink update="@form" oncomplete="showPopup(false);" 
                                                                                       actionListener="#{DatasetPage.startDownloadAllArchival()}" styleClass="btn-download">
                                                                                #{bundle.downloadArchival}
                                                                            <h:outputFormat value="#{bundle['dataset.accessBtn.download.size']}">
                                                                                <f:param value="#{sizeOfDataset}" />
                                                                            </h:outputFormat>
                                                                        </p:commandLink>
                                                                    </li>
                                                                    <!-- Archival Format too big -->
                                                                    <ui:fragment rendered="#{tooLargeToDownloadArchival}">                                                                                                                               
                                                                        <h:outputText value="#{bundle['dataset.accessBtn.archival.too.big']}">                                           
                                                                        </h:outputText>                                                            
                                                                    </ui:fragment>
                                                                </ui:fragment>
                                                            </ui:fragment>
                                                            <!-- Can Download, but Download either format too big-->
                                                            <ui:fragment rendered="#{tooLargeToDownload}">                                                                                                                               
                                                                <h:outputText value="#{bundle['dataset.accessBtn.too.big']}">                                           
                                                                </h:outputText>                                                            
                                                            </ui:fragment>
                                                        </ui:fragment>
                                                        <ui:fragment rendered="#{versionHasGlobus}">
                                                            <li>
                                                                <p:commandLink update="@form" oncomplete="showPopup(true);" 
                                                                                   actionListener="#{DatasetPage.startGlobusTransfer(true, false)}" styleClass="btn-download">
                                                                            #{bundle.transfer}
                                                                    <h:outputFormat value="#{bundle['dataset.accessBtn.transfer.size']}">
                                                                        <f:param value="#{sizeOfDataset}" />
                                                                    </h:outputFormat>
                                                                    <f:actionListener binding="#{DatasetPage.setTermsGuestbookPopupAction(bundle.download)}"/>
                                                                    </p:commandLink>
                                                            </li>
                                                        </ui:fragment>
                                                            

                                                                                                            
                                                        <!-- END: DOWNLOAD -->
                                                       
                                                        <!-- EXPLORE -->
                                                        <ui:fragment rendered="#{datasetExploreToolsSize >= 1}">
                                                            <li class="dropdown-header">#{bundle['dataset.accessBtn.header.explore']} <span class="glyphicon glyphicon-equalizer"/></li>
                                                            <!-- Explore tool links -->
                                                            <ui:repeat var="tool" value="#{DatasetPage.datasetExploreTools}">
                                                                <li>
                                                                    <h:commandLink styleClass="btn-explore" action="#{DatasetPage.explore(tool)}">
                                                                        <h:outputText value="#{tool.getDisplayNameLang()}"/>
                                                                    </h:commandLink>
                                                                </li>
                                                            </ui:repeat>
                                                        </ui:fragment>
                                                        <!-- END: EXPLORE -->

                                                        <!-- COMPUTE -->
                                                        <ui:fragment rendered="#{sessionUserAuthenticated
                                                                                    and showComputeButton}">
                                                            <li class="dropdown-header">#{bundle['dataset.accessBtn.header.compute']} <span class="glyphicon glyphicon-flash"/></li>
                                                            <li>
                                                                <a tabindex="0" id="computeBatch" class="btn-compute">#{bundle['dataset.compute.computeBtn']}</a>
                                                                <ul class="dropdown-menu">
                                                                    <li>
                                                                        <!-- Compute dataset link -->
                                                                        <h:commandLink action="#{DatasetPage.canComputeAllFiles(false)}">
                                                                            <h:outputText value="#{bundle['dataset.compute.computeBatchSingle']}"/>
                                                                        </h:commandLink>
                                                                    </li>
                                                                    <li jsf:rendered="#{!DatasetPage.isCartEmpty()}" class="divider"></li>
                                                                    <li jsf:rendered="#{!DatasetPage.checkCartForItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}">
                                                                        <!-- Add link -->
                                                                        <p:commandLink action="#{DatasetPage.addItemtoCart(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}"
                                                                                       disabled="#{DatasetPage.locked}" value="#{bundle['dataset.compute.computeBatchAdd']}" update=":datasetForm,:messagePanel">
                                                                            <h:outputText value="#{bundle['dataset.compute.computeBatchAdd']}"/>
                                                                        </p:commandLink>
                                                                    </li>
                                                                    <ui:fragment rendered="#{!DatasetPage.isCartEmpty()}">
                                                                        <li jsf:rendered="#{DatasetPage.checkCartForItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}">
                                                                            <!-- Remove link -->
                                                                            <p:commandLink value="#{bundle['dataset.compute.computeBatchRemove']}" action="#{DatasetPage.removeCartItem(DatasetPage.dataset.getDisplayName(), DatasetPage.getPersistentId())}" update=":datasetForm,:messagePanel">
                                                                                <h:outputText value="#{bundle['dataset.compute.computeBatchRemove']}"/>
                                                                            </p:commandLink>
                                                                        </li>
                                                                        <li>
                                                                            <!-- List link -->
                                                                            <p:commandLink title="#{bundle['dataset.compute.computeBatchList']}"
                                                                                           value="#{bundle['dataset.compute.computeBatchList']}"
                                                                                           oncomplete="PF('computeBatchListPopup').show();"
                                                                                           update="computeBatchListPopup">
                                                                                <h:outputText value="#{bundle['dataset.compute.computeBatchList']}"/>
                                                                            </p:commandLink>
                                                                        </li>
                                                                        <li>
                                                                            <!-- Clear link -->
                                                                            <p:commandLink value="#{bundle['dataset.compute.computeBatchClear']}" action="#{DatasetPage.clearCart()}" update=":datasetForm,:messagePanel">
                                                                                <h:outputText value="#{bundle['dataset.compute.computeBatchClear']}"/>
                                                                            </p:commandLink>
                                                                        </li>
                                                                        <li>
                                                                            <!-- Compute batch link -->
                                                                            <h:outputLink value="#{DatasetPage.cartComputeUrl}" target="_blank">
                                                                                <h:outputText id="compute-batch-button" value="#{bundle['dataset.compute.computeBatchCompute']}" />
                                                                            </h:outputLink>
                                                                        </li>
                                                                    </ui:fragment>
                                                                </ul>
                                                            </li>
                                                        </ui:fragment>
                                                        <!-- END: COMPUTE -->
                                                    </ul>
                                                </div>
                                            </div>
                                            <!-- END: DOWNLOAD/ACCESS DATASET -->

                                            <!-- PUBLISH DATASET -->
                                            <div class="btn-group btn-group-justified" jsf:rendered="#{showPublishLink or showSubmitForReviewLink}">
                                                <div class="btn-group">
                                                    <!-- Publish BTN -->
                                                    <h:outputLink value="#" disabled="#{DatasetPage.lockedFromPublishing or !DatasetPage.hasValidTermsOfAccess or !valid}">
                                                        <c:if test="#{!((showSubmitForReviewLink or showReturnToAuthorLink) and showPublishLink )}">
                                                            <f:passThroughAttribute name="class" value="btn btn-default btn-access btn-publish #{DatasetPage.lockedFromPublishing or !DatasetPage.hasValidTermsOfAccess or !valid ? 'disabled' : ''}"/>
                                                            <f:passThroughAttribute name="onclick" value="$(this).parent().find( 'li > a' ).trigger( 'click' );"/>
                                                        </c:if>
                                                        <c:if test="#{(showSubmitForReviewLink or showReturnToAuthorLink) and showPublishLink}">
                                                            <f:passThroughAttribute name="class" value="btn btn-default btn-access btn-publish dropdown-toggle #{DatasetPage.lockedFromPublishing or !DatasetPage.hasValidTermsOfAccess  or !valid ? 'disabled' : ''}"/>
                                                            <f:passThroughAttribute name="data-toggle" value="dropdown"/>
                                                            <f:passThroughAttribute name="aria-haspopup" value="true"/>
                                                            <f:passThroughAttribute name="aria-expanded" value="false"/>
                                                        </c:if>
                                                        #{showPublishLink ? bundle['dataset.publishBtn'] : (latestVersionInReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn'])} <span jsf:rendered="#{(showSubmitForReviewLink or showReturnToAuthorLink) and showPublishLink}" class="caret"></span>
                                                    </h:outputLink>
                                                    <!-- Publish BTN DROPDOWN-MENU OPTIONS -->
                                                    <ul class="dropdown-menu pull-right text-left">
                                                        <li jsf:rendered="#{showPublishLink}" class="#{!DatasetPage.hasValidTermsOfAccess or ( DatasetPage.locked and !latestVersionInReview) ? 'disabled' : ''}">
                                                            <!-- Publish LINK -->
                                                            <p:commandLink styleClass="#{!DatasetPage.hasValidTermsOfAccess or (DatasetPage.locked and !latestVersionInReview) ? 'disabled' : ''}" 
                                                                           disabled="#{!DatasetPage.hasValidTermsOfAccess or (DatasetPage.locked and !latestVersionInReview)}"
                                                                           action="#{DatasetPage.processPublishButton()}">
                                                                #{bundle['dataset.publish.btn']}
                                                            </p:commandLink>
                                                        </li>
                                                        <li jsf:rendered="#{showSubmitForReviewLink}" class="#{latestVersionInReview or DatasetPage.dataset.locked ? 'disabled' : ''}">
                                                            <!-- Submit for Review LINK -->
                                                            <p:commandLink class="#{latestVersionInReview or DatasetPage.dataset.locked ? 'disabled' : ''}" 
                                                                           disabled="#{latestVersionInReview or DatasetPage.dataset.locked}"
                                                                           onclick="PF('inreview').show()">
                                                                #{latestVersionInReview ? bundle['dataset.disabledSubmittedBtn'] : bundle['dataset.submitBtn']}
                                                            </p:commandLink>
                                                        </li>
                                                        <li jsf:rendered="#{showReturnToAuthorLink}" class="#{(DatasetPage.locked and !latestVersionInReview) ? 'disabled' : ''}">
                                                            <!-- Return to Author LINK -->
                                                            <p:commandLink class="#{(DatasetPage.locked and !latestVersionInReview) ? 'disabled' : ''}" 
                                                                           disabled="#{DatasetPage.locked and !latestVersionInReview}"
                                                                           onclick="PF('sendBackToContributor').show()">
                                                                #{bundle['dataset.rejectBtn']}
                                                            </p:commandLink>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                            <!-- END: Publish -->

                                            <!-- Edit Dataset -->
                                            <div class="btn-group btn-group-justified" jsf:rendered="#{sessionUserAuthenticated
                                                                                                        and canUpdateDataset}">
                                                <div class="btn-group">
                                                    <button type="button" id="editDataSet" class="btn btn-default btn-access btn-edit dropdown-toggle #{DatasetPage.lockedFromEdits ? 'disabled' : ''}" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"
                                                            disabled="#{DatasetPage.lockedFromEdits ? 'disabled' : ''}">
                                                        #{bundle['dataset.editBtn']} <span class="caret"></span>
                                                    </button>
                                                    <ul class="dropdown-menu pull-right text-left">
                                                        <li>
                                                            <h:outputLink value="/editdatafiles.xhtml?datasetId=#{DatasetPage.dataset.id}&#38;mode=UPLOAD" rendered="#{DatasetPage.hasValidTermsOfAccess}">
                                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.upload']}"/>
                                                            </h:outputLink>
                                                        </li>
                                                        <li style="margin-left:20px;margin-bottom:2px;">
                                                            <p:commandLink rendered="#{!DatasetPage.hasValidTermsOfAccess}" disabled="#{!DatasetPage.hasValidTermsOfAccess}" >
                                                                <h:outputText  value="#{bundle['dataset.editBtn.itemLabel.upload']}" />
                                                            </p:commandLink>
                                                        </li>                                                    
                                                        <li style="margin-left:20px;">
                                                            <p:commandLink id="editMetadataDisabled" onclick="editMetadata()" rendered="#{!DatasetPage.hasValidTermsOfAccess}" disabled="#{!DatasetPage.hasValidTermsOfAccess}" >
                                                                <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.metadata']}"  />
                                                            </p:commandLink>
                                                        </li> 
                                                        <li>
                                                            <p:commandLink id="editMetadata" onclick="editMetadata()" rendered="#{DatasetPage.hasValidTermsOfAccess}">
                                                                <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.metadata']}"  />
                                                            </p:commandLink>
                                                        </li>
                                                        <li>
                                                            <p:commandLink id="editTerms" actionListener="#{DatasetPage.edit('LICENSE')}" update="@form,:datasetForm,:messagePanel">
                                                                <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.terms']}" />
                                                            </p:commandLink>
                                                        </li>
                                                        <ui:fragment rendered="#{permissionsWrapper.canManagePermissions(DatasetPage.dataset) || permissionsWrapper.canManageFilesOnDataset(DatasetPage.dataset)}">
                                                            <li class="#{DatasetPage.hasPublicStore ? '' : 'dropdown-submenu pull-left'}">
                                                                <ui:fragment rendered="#{!DatasetPage.hasPublicStore}">
                                                                <a tabindex="0">#{bundle['dataset.editBtn.itemLabel.permissions']}</a>
                                                                    <ul class="dropdown-menu">
                                                                        <li jsf:rendered="#{permissionsWrapper.canManagePermissions(DatasetPage.dataset)}">
                                                                            <h:link id="manageDatasetPermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                                                <h:outputText value="#{bundle['dataset']}" />
                                                                                <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                                            </h:link>
                                                                        </li>
                                                                        <li jsf:rendered="#{permissionsWrapper.canManageFilesOnDataset(DatasetPage.dataset)}">
                                                                            <h:link id="manageFilePermissions" styleClass="ui-commandlink ui-widget" outcome="permissions-manage-files">
                                                                                <h:outputText value="#{bundle['file']}" />
                                                                                <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                                            </h:link>
                                                                        </li>
                                                                    </ul>
                                                                </ui:fragment>
                                                                <h:link id="managePermissions" rendered="#{DatasetPage.hasPublicStore}"
                                                                        styleClass="ui-commandlink ui-widget" outcome="permissions-manage">
                                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.permissions']}" />
                                                                    <f:param name="id" value="#{DatasetPage.dataset.id}" />
                                                                </h:link>
                                                            </li>
                                                            <li>
                                                                <p:commandLink id="privateUrl" oncomplete="PF('privateUrlConfirmation').show()" action="#{DatasetPage.initPrivateUrlPopUp()}" update="privateUrlPanel">
                                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.privateUrl']}" />
                                                                </p:commandLink>
                                                            </li>
                                                        </ui:fragment>
                                                        <li>
                                                            <h:outputLink value="/dataset-widgets.xhtml?datasetId=#{DatasetPage.dataset.id}">
                                                                <h:outputText value="#{bundle['dataset.editBtn.itemLabel.thumbnailsAndWidgets']}"/>
                                                            </h:outputLink>
                                                        </li>
                                                        <ui:fragment rendered="#{DatasetPage.datasetConfigureTools.size() >= 1}">
                                                            <li class="dropdown-header">#{bundle['dataset.accessBtn.header.configure']} <span class="glyphicon glyphicon-cog"/></li>
                                                            <!-- Configure tool links -->
                                                            <ui:repeat var="tool" value="#{DatasetPage.datasetConfigureTools}">
                                                                <li>
                                                                    <p:commandLink styleClass="btn-explore" actionListener="#{DatasetPage.setDatasetConfigureTool(tool)}" process="@this" update="datasetForm:configureToolDialog" oncomplete="PF('configureToolDialog').show();">
                                                                        <h:outputText value="#{tool.getDisplayNameLang()}"/>
                                                                    </p:commandLink>
                                                                </li>
                                                            </ui:repeat>
                                                        </ui:fragment>
                                                        <ui:fragment rendered="#{!DatasetPage.dataset.released and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and permissionsWrapper.canIssueDeleteDatasetCommand(DatasetPage.dataset)}">
                                                            <li role="separator" class="divider"></li>
                                                            <li>
                                                                <p:commandLink id="deleteDataset" onclick="PF('deleteConfirmation').show()">
                                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deleteDataset']}" />
                                                                </p:commandLink>
                                                            </li>
                                                        </ui:fragment>
                                                        <ui:fragment rendered="#{DatasetPage.dataset.released and DatasetPage.dataset.latestVersion.versionState=='DRAFT' and permissionsWrapper.canIssueDeleteDatasetCommand(DatasetPage.dataset)}">
                                                            <li role="separator" class="divider"></li>
                                                            <li>
                                                                <p:commandLink id="deleteVersion" onclick="PF('deleteVersionConfirmation').show()">
                                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deleteDraft']}" />
                                                                </p:commandLink>
                                                            </li>
                                                        </ui:fragment>
                                                        <ui:fragment rendered="#{DatasetPage.dataset.released and DatasetPage.existReleasedVersion and canIssuePublishDatasetCommand}">
                                                            <li role="separator" class="divider"></li>
                                                            <li>
                                                                <p:commandLink id="deaccessionDatasetLink" 
                                                                               action="#{DatasetPage.clickDeaccessionDataset}"
                                                                               oncomplete="PF('deaccessionBlock').show();"
                                                                               update="deaccessionBlock">
                                                                    <h:outputText value="#{bundle['dataset.editBtn.itemLabel.deaccession']}" />
                                                                </p:commandLink>
                                                            </li>
                                                        </ui:fragment>
                                                    </ul>
                                                </div>
                                            </div>
                                            <!-- END: Edit Dataset -->
                                            <!-- Curation Status -->
                                            <div class="btn-group btn-group-justified" jsf:rendered="#{canSeeCurationStatus and not empty DatasetPage.allowedCurationStatuses}">
                                              <div class="btn-group">
                                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                                    #{bundle['dataset.curationStatusMenu']} <span class="caret"></span>
                                                </button>
                                                <ul class="dropdown-menu multi-level pull-right text-left">
                                                    <ui:fragment rendered="#{(not empty DatasetPage.allowedCurationStatuses) and DatasetPage.canPublishDataset() and version.draft}">
                                                    <li class="dropdown-submenu pull-left">
                                                        <a tabindex="0">#{bundle['dataset.changestatus']}</a>
                                                        <ul class="dropdown-menu">
                                                            <ui:repeat value="#{DatasetPage.allowedCurationStatuses}" var="status">
                                                                <li>
                                                                    <o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
                                                                    <p:commandLink action="#{DatasetPage.setCurationStatus(status)}" update=":datasetForm:topDatasetBlockFragment,:messagePanel">
                                                                        #{DatasetUtil:getLocaleCurationStatusLabelFromString(status)}
                                                                    </p:commandLink>
                                                                </li>
                                                            </ui:repeat>
                                                            <p:separator/>
                                                            <li>
                                                                <p:commandLink action="#{DatasetPage.setCurationStatus(null)}" update=":datasetForm:topDatasetBlockFragment,:messagePanel">
                                                                    #{bundle['dataset.removestatus']}
                                                                </p:commandLink>
                                                            </li>
                                                        </ul>
                                                    </li>
                                                    </ui:fragment>
                                                    <li>
                                                        <p:commandLink oncomplete="PF('curationStatusHistoryDialog').show()"
                                                            update=":datasetForm:curationStatusHistoryDialog"
                                                            rendered="#{canSeeCurationStatus}">
                                                            #{bundle['dataset.viewCurationStatusHistory']}
                                                        </p:commandLink>
                                                     </li>
                                                </ul>
                                              </div>
                                            </div>
                                            <!-- END: Curation Status -->
                                            <!-- LINK -->
                                            <div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !deaccessioned}">
                                                <p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
                                                               action="#{DatasetPage.setShowLinkingPopup(true)}"
                                                               oncomplete="PF('linkDatasetForm').show();"
                                                               update="@form">
                                                    #{bundle['dataset.linkBtn']}
                                                </p:commandLink>
                                            </div>
                                            <!-- END: LINK -->
                                            <!-- UNLINK -->
                                            <div class="btn-group btn-group-justified" jsf:rendered="#{dataverseSession.user.authenticated and !deaccessioned and !empty DatasetPage.dataset.datasetLinkingDataverses}">
                                                <p:commandLink styleClass="btn btn-default btn-access btn-xs btn-block btn-link-dataset"
                                                               action="#{DatasetPage.setShowUnLinkingPopup(true)}"
                                                               oncomplete="PF('unlinkDatasetForm').show();"
                                                               update="@form">
                                                    #{bundle['dataset.unlinkBtn']}
                                                </p:commandLink>
                                            </div>
                                            <!-- END: UNLINK -->

                                            <!-- Contact/Share Button Group -->
                                            <div class="btn-group btn-group-justified">
                                                <p:commandLink styleClass="btn btn-default btn-xs btn-contact" title="#{bundle['dataset.email.datasetContactTitle']}"
                                                               update=":contactDialog" oncomplete="PF('contactForm').show()" actionListener="#{sendFeedbackDialog.initUserInput}">
                                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                                    <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{DatasetPage.dataset}"/>
                                                    #{bundle['dataset.contactBtn']}
                                                </p:commandLink>
                                                <p:commandLink styleClass="btn btn-default btn-xs btn-share" rendered="#{!deaccessioned}"
                                                               title="#{bundle['dataset.share.datasetShare']}"
                                                               oncomplete="PF('shareDialog').show();sharrre();">
                                                    #{bundle['dataset.shareBtn']}
                                                </p:commandLink>
                                            </div>
                                            <!-- END: Contact/Share Button Group -->
                                        </div>
                                        <!-- END: ActionButtonBlock -->
                                    </div>

                                    <div style="clear:right;" class="col-xs-12 col-sm-12 col-md-4 col-lg-3 pull-right margin-bottom" 
                                         jsf:rendered="#{!(settingsWrapper.rsyncDownload or deaccessioned)}">
                                        <!-- Metrics -->
                                        <div id="metrics-block">
                                            <div id="metrics-heading">
                                                #{settingsWrapper.makeDataCountDisplayEnabled ? bundle['metrics.dataset.makedatacount.title'] : bundle['metrics.dataset.title']}
                                                <ui:fragment rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
                                                    <span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top" 
                                                          data-trigger="hover" data-original-title="#{bundle['metrics.dataset.tip.default']}"></span>
                                                </ui:fragment>
                                                <ui:fragment rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
                                                    <a tabindex="0" role="button" class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="popover" data-placement="auto top" 
                                                       data-trigger="focus" data-html="true" data-content="#{bundle['metrics.dataset.tip.makedatacount']}"></a>
                                                        <div id="metrics-heading-subtitle">#{bundle['metrics.dataset.makedatacount.since']} #{settingsWrapper.getMDCStartDate().toString()}</div>
                                                </ui:fragment>
                                                
                                            </div>
                                            <div id="metrics-body">
                                                <!-- Classic downloads -->
                                                <div class="metrics-count-block" jsf:rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
                                                    <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                        <f:param value="#{guestbookResponseServiceBean.getDownloadCountByDatasetId(DatasetPage.dataset.id)}"/>
                                                    </h:outputFormat>
                                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                          data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.default.tip']}"></span>
                                                </div>
                                                <!-- Make Data Count views -->
                                                <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
                                                    <h:outputFormat value="{0} #{bundle['metrics.views']}">
                                                        <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getViewsTotal()}"/>
                                                    </h:outputFormat>
                                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                          data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.views.tip']}"></span>
                                                </div>
                                                <!-- Make Data Count downloads -->
                                                <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
                                                    <h:outputFormat value="{0} #{bundle['metrics.downloads']}">
                                                        <f:param value="#{datasetMetricsServiceBean.getMetrics(DatasetPage.dataset).getDownloadsTotal()}"/>
                                                    </h:outputFormat>
                                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                          data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.makedatacount.tip']}"></span>
                                                    <span jsf:rendered="#{settingsWrapper.getMDCStartDate()!=null and guestbookResponseServiceBean.getDownloadCountByDatasetId(DatasetPage.dataset.id, settingsWrapper.getMDCStartDate()) > 0 }">        
                                                        <h:outputFormat value="#{bundle['metrics.downloads.nonMDC']}">
                                                            <f:param value="#{guestbookResponseServiceBean.getDownloadCountByDatasetId(DatasetPage.dataset.id, settingsWrapper.getMDCStartDate())}"/>
                                                        </h:outputFormat>
                                                        <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                            data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.downloads.premakedatacount.tip']}"></span>)
                                                    </span>
                                                </div>
                                                <!-- Make Data Count citations (DOIs only, not Handles) -->
                                                <div class="metrics-count-block" jsf:rendered="#{settingsWrapper.makeDataCountDisplayEnabled and DatasetPage.DOI}">
                                                    <p:commandLink oncomplete="PF('citationsDialog').show();">
                                                        <h:outputFormat value="{0} #{bundle['metrics.citations']}">
                                                            <f:param value="#{fn:length(datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset))}"/>
                                                        </h:outputFormat>
                                                    </p:commandLink>
                                                    <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                          data-toggle="tooltip" data-placement="auto top" data-original-title="#{bundle['metrics.dataset.citations.tip']}"></span>
                                                </div>
                                            </div>
                                        </div>
                                        <!-- END: Metrics -->
                                    </div>

                                    <!-- RESPONSIVE ORDER HACK BOOTSTRAP 3 https://stackoverflow.com/a/24834574 -->
                                    <div id="dataset-colorder-block" class="visible-md-block visible-lg-block col-md-8 col-lg-9"><!--Hack--></div>
                                    <!-- END: RESPONSIVE ORDER HACK BOOTSTRAP 3 -->

                                    <!-- DEACCESSION REASON -->
                                   <div class="col-xs-12 col-sm-12 col-md-8 col-lg-9 margin-bottom" jsf:rendered="#{deaccessioned}">
                                        <div id="deaccession-reason-block" class="col-xs-12 bg-danger">
                                            <h5 class="margin-top-half">#{bundle['dataset.deaccession.reason']}</h5>
                                            <p>#{version.deaccessionNote}</p>
                                            <ui:fragment rendered="#{!empty version.deaccessionLink}">
                                                <p>#{bundle['dataset.beAccessedAt']}
                                                    <h:outputLink rendered="#{version.deaccessionLinkAsURLString ne null}" value="#{version.deaccessionLinkAsURLString}" target="_blank">#{version.deaccessionLink}</h:outputLink>
                                                    <h:outputText rendered="#{version.deaccessionLinkAsURLString eq null}" value="#{version.deaccessionLink}"/>
                                                </p>
                                            </ui:fragment>
                                        </div>
                                    </div>
                                    <!-- END: DEACCESSION REASON -->

                                    <!-- BEGIN: DATASET SUMMARY -->
                                    <div id="dataset-summary-metadata" class="col-xs-12 col-sm-12 col-md-8 col-lg-9 metadata-container padding-none margin-bottom">
                                        <table class="metadata">
                                            <tbody>
                                                <ui:repeat value="#{DatasetPage.datasetSummaryFields}" var="dsf">
                                                    <tr id="keywords" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.keywordDisplay and dsf.datasetFieldType.id==DatasetPage.datasetVersionUI.keyword.datasetFieldType.id}">
                                                        <th scope="row">
                                                            #{bundle['dataset.keywordDisplay.title']}
                                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{DatasetPage.datasetVersionUI.keyword.datasetFieldType.localeDescription}"></span>
                                                        </th>
                                                        <td>#{DatasetPage.datasetVersionUI.keywordDisplay}</td>
                                                    </tr>
                                                    <tr id="publication" jsf:rendered="#{!empty DatasetPage.datasetVersionUI.relPublicationCitation and dsf.datasetFieldType.name=='publication'}">
                                                        <th scope="row">
                                                            #{DatasetPage.datasetVersionUI.datasetRelPublications.get(0).title}
                                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{DatasetPage.datasetVersionUI.datasetRelPublications.get(0).description}"></span>
                                                        </th>
                                                        <td jsf:rendered="#{!anonymizedAccess or !settingsWrapper.shouldBeAnonymized(dsf)}">
                                                          <h:outputText value="#{DatasetPage.datasetVersionUI.relPublicationRelationType}#{MarkupChecker:sanitizeBasicHTML(DatasetPage.datasetVersionUI.relPublicationCitation)}" escape="false"/>
                                                        
                                                          <span jsf:rendered="#{!empty DatasetPage.datasetVersionUI.relPublicationUrl}"><a href="#{DatasetPage.datasetVersionUI.relPublicationUrl}" title="#{DatasetPage.datasetVersionUI.relPublicationUrl}" target="_blank" rel="noopener">#{empty DatasetPage.datasetVersionUI.relPublicationId ?  DatasetPage.datasetVersionUI.relPublicationUrl:DatasetPage.datasetVersionUI.relPublicationId}</a></span>
                                                          <h:outputText rendered="#{empty DatasetPage.datasetVersionUI.relPublicationUrl}" value="#{DatasetPage.datasetVersionUI.relPublicationId}"/>
                                                        </td>
                                                        <td jsf:rendered="#{anonymizedAccess and settingsWrapper.shouldBeAnonymized(dsf)}">
                                                            <h:outputText value="#{bundle['dataset.anonymized.withheld']}"/>
                                                        </td>
                                                    </tr>
                                                    <tr id="#{dsf.datasetFieldType.name}" jsf:rendered="#{dsf.datasetFieldType.name!='publication' and dsf.datasetFieldType.name!='keyword'}">
                                                        <th scope="row">
                                                            #{dsf.datasetFieldType.localeTitle}
                                                            <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                                                  data-toggle="tooltip" data-placement="auto right" data-original-title="#{dsf.datasetFieldType.localeDescription}"></span>
                                                        </th>
                                                        <td jsf:rendered="#{!anonymizedAccess or !settingsWrapper.shouldBeAnonymized(dsf)}">
                                                            <!-- Primitive datasetFields -->
                                                            <ui:fragment rendered="#{dsf.datasetFieldType.primitive}">
                                                                <h:outputText value="#{dsf.displayValue}" rendered="#{!dsf.datasetFieldType.allowMultiples}"
                                                                              escape="#{dsf.datasetFieldType.isEscapeOutputText()}"/>
                                                                <ui:repeat value="#{dsf.values}" var="value" varStatus="loop" rendered="#{dsf.datasetFieldType.allowMultiples}">
                                                                    <h:outputText value="#{loop.first?'':'; '}#{ value }"
                                                                                  escape="#{dsf.datasetFieldType.isEscapeOutputText()}"/>
                                                                </ui:repeat>
                                                            </ui:fragment>
                                                            <!-- Compound datasetFields -->
                                                            <ui:fragment rendered="#{dsf.datasetFieldType.compound}">
                                                                <ui:fragment rendered="#{dsf.datasetFieldType.name == 'datasetContact'}">
                                                                    <p class="help-block">
                                                                        <h:outputText value="#{bundle['dataset.contact.tip']}"/>
                                                                    </p>
                                                                </ui:fragment>
                                                                <ui:repeat value="#{dsf.datasetFieldCompoundValues}" var="compoundValue">
                                                                    <div>
                                                                        <ui:repeat value="#{compoundValue.displayValueMap.entrySet().toArray()}" var="cvPart" varStatus="partStatus">
                                                                            <h:outputText value="#{dsf.datasetFieldType.displayFormat} " rendered="${!partStatus.first}"/>
                                                                            <h:outputText value="#{cvPart.value}"
                                                                                          escape="#{cvPart.key.datasetFieldType.isEscapeOutputText()}"/>
                                                                        </ui:repeat>
                                                                    </div>
                                                                </ui:repeat>
                                                            </ui:fragment>
                                                        </td>
                                                        <td jsf:rendered="#{anonymizedAccess and settingsWrapper.shouldBeAnonymized(dsf)}">
                                                            <h:outputText value="#{bundle['dataset.anonymized.withheld']}"/>
                                                        </td>
                                                    </tr>
                                                </ui:repeat>
                                                <tr>
                                                    <th scope="row">
                                                        #{bundle['file.dataFilesTab.terms.list.license']}
                                                    </th>
                                                    <td>
                                                        <p>
                                                            <o:importFunctions type="edu.harvard.iq.dataverse.dataset.DatasetUtil" />
                                                            <img src="#{DatasetUtil:getLicenseIcon(version)}" title="#{DatasetUtil:getLicenseDescription(version)}" style="display:none"  onload="this.style.display='inline'" />
                                                            <a href="#{DatasetUtil:getLicenseURI(version)}" title="#{DatasetUtil:getLicenseDescription(version)}" target="_blank">#{DatasetUtil:getLicenseName(version)}</a>
                                                        </p>
                                                    </td>
                                                </tr>
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- END: DATASET SUMMARY -->
                                </div>
                                <!-- END: NEW RESPONSIVE ABOVE FOLD BLOCK -->
                            </div>
                        </div>
                    </p:fragment>
                    <!-- END Top Button/Citation Blocks -->
                    <!-- END View infoMode -->

                    <!-- Create/Edit editMode -->
                    <ui:fragment rendered="#{DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'CREATE'}">
                        <p:focus context="datasetForm"/>
                        <div class="form-group" jsf:rendered="#{DatasetPage.hasDataversesToChoose and DatasetPage.editMode == 'CREATE'}">
                            <label jsf:for="#{DatasetPage.editMode == 'CREATE' ? 'selectHostDataverse_input' : 'select_HostDataverse_Static'}" class="col-md-3 control-label">
                                #{bundle.hostDataverse}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataverse.host.title']}"></span>
                            </label>
                            <div class="col-md-7">
                                <ui:fragment rendered="#{DatasetPage.editMode == 'METADATA'}">
                                    <p jsf:id="select_HostDataverse_Static" class="form-control-static">#{DatasetPage.dataset.owner.name}</p>
                                    <h:inputHidden value="#{DatasetPage.ownerId}" id="select_HostDataverseStatic"/>
                                </ui:fragment>
                                <ui:fragment rendered="#{DatasetPage.editMode == 'CREATE'}">
                                    <p class="help-block">
                                        #{bundle['dataset.host.tip']}
                                    </p>
                                    <div class="form-group">
                                        <p:fragment id="hostDataverseContent">
                                            <p:autoComplete id="selectHostDataverse"
                                                            placeholder="#{bundle['dataverse.link.yourDataverses.inputPlaceholder']}"
                                                            emptyMessage="#{bundle['dataverse.host.autocomplete.nomatches']}"
                                                            scrollHeight="180" forceSelection="true" 
                                                            minQueryLength="1" queryDelay="1000"
                                                            value="#{DatasetPage.selectedHostDataverse}" 
                                                            multiple="false"
                                                            completeMethod="#{DatasetPage.completeHostDataverseMenuList}"
                                                            required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
                                                            styleClass="DropdownPopup" panelStyleClass="DropdownPopupPanel"
                                                            var="hostDataverse" itemLabel="#{hostDataverse.displayName}" itemValue="#{hostDataverse}" converter="dataverseConverter">
                                                <p:column>
                                                    <h:outputText value="#{hostDataverse.displayName}"/>
                                                </p:column>
                                                <p:column>
                                                    <h:outputText value="#{hostDataverse.alias}"/>
                                                </p:column>
                                                <p:ajax process="@this" event="itemSelect" oncomplete="updateOwnerDataverse()"/>
                                                <p:ajax process="@this" event="itemUnselect" oncomplete="updateOwnerDataverse()"/>
                                            </p:autoComplete>
                                            <p:message for="selectHostDataverse"/>
                                            <p:commandButton id="updateOwnerDataverse"
                                                             style="display:none"
                                                             process="@this :datasetForm:hostDataverseContent"
                                                             update="@form,:breadCrumbPanel"
                                                             action="#{DatasetPage.updateOwnerDataverse()}">
                                            </p:commandButton>
                                        </p:fragment>
                                    </div>
                                </ui:fragment>
                            </div>
                        </div>
                        <div class="form-group" jsf:rendered="#{!empty DatasetPage.dataverseTemplates and DatasetPage.editMode == 'CREATE'}">
                            <label jsf:for="select_DatasetTemplate" class="col-md-3 control-label">
                                #{bundle['dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate']}
                                <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                      data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.manageTemplates.tab.action.btn.view.dialog.datasetTemplate.title']}"></span>
                            </label>
                            <div class="col-md-7">
                                <p class="help-block">
                                    #{bundle['dataset.template.tip']}
                                </p>
                                <p:selectOneMenu value="#{DatasetPage.selectedTemplate}" onchange="updateTemplate()"
                                                 converter="templateConverter" id="select_DatasetTemplate" styleClass="form-control"
                                                 valueChangeListener="#{DatasetPage.updateSelectedTemplate}"
                                                 style="width:auto !important; max-width:100%; min-width:200px;">
                                    <f:selectItem itemLabel="#{bundle['dataset.noTemplate.label']}" itemValue="#{null}" />
                                    <f:selectItems value="#{DatasetPage.dataverseTemplates}"
                                                   var="template" itemLabel="#{template.name}" itemValue="#{template}"/>
                                </p:selectOneMenu>
                                <p:commandButton value="#{bundle['file.dataFilesTab.button.direct']}" id="updateTemplate"
                                                 style="display:none"
                                                 update=":datasetForm,accessPopup"
                                                 action="#{DatasetPage.handleChangeButton}">
                                </p:commandButton>
                            </div>
                        </div>

                    </ui:fragment>
                    <ui:fragment rendered="#{DatasetPage.editMode == 'CREATE'}">
                        <ui:include src="metadataFragment.xhtml">
                            <ui:param name="datasetPage" value="true"/>
                            <ui:param name="template" value="#{DatasetPage.dataset.template}"/>
                            <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? DatasetPage.editMode : ''}"/>
                            <ui:param name="metadataBlocks" value="#{!empty DatasetPage.editMode ? DatasetPage.datasetVersionUI.metadataBlocksForEdit.entrySet().toArray(): DatasetPage.datasetVersionUI.metadataBlocksForView.entrySet().toArray()}"/>
                            <!-- ui:param name="publicationDate" value="#{DatasetPage.dataset.publicationDateFormattedYYYYMMDD}"/-->
                            <ui:param name="globalId" value="#{DatasetPage.dataset.globalId.asString()}"/>
                            <ui:param name="mdLang" value="#{DatasetPage.getLocaleDisplayName(DatasetPage.getEffectiveMetadataLanguage(true))}"/>
                            <ui:param name="mdLangCode" value="#{DatasetPage.getEffectiveMetadataLanguage(true)}"/>
                        </ui:include>
                    </ui:fragment>
                    <!-- Create/Save Dataset Button Panel TOP editMode -->
                    <div class="button-block form-top" jsf:rendered="#{DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'LICENSE'}">
                        <p:commandButton id="saveTop" styleClass="btn btn-default" value="#{bundle.saveChanges}" rendered="#{DatasetPage.editMode == 'METADATA'}"
                                         onclick="PF('blockDatasetForm').show();"
                                         update=":datasetForm,:messagePanel"
                                         oncomplete="$(document).scrollTop(0);"
                                         action="#{DatasetPage.save}"
                                         />
                        <p:commandButton id="saveTopTOA" styleClass="btn btn-default" value="#{bundle.saveChanges}" rendered="#{DatasetPage.editMode == 'LICENSE'}"
                                         onclick="testTOADatasetPage();"
                                         oncomplete="$(document).scrollTop(0);"
                        />
                        <p:commandButton id="cancelTop" styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.cancel}" process="@this" update="@form">
                            <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="#{DatasetPage.editMode == 'METADATA' ? 1 : DatasetPage.selectedTabIndex}"/>
                        </p:commandButton>
                    </div>
                    <!-- END Create/Save Dataset Button Panel TOP editMode -->
                    <!-- END Create/Edit editMode -->
                    <!-- View/Tabs infoMode -->
                    <div id="contentTabs" jsf:rendered="#{DatasetPage.editMode != 'INFO'}">
                        <p:fragment id="pageRefreshFragment"> <!-- rendered="_{empty DatasetPage.editMode}" -->
                            <h:inputHidden value="#{DatasetPage.lockedForAnyReason}" id="datasetLockedForAnyReasonVariable" />
                            <h:inputHidden value="#{DatasetPage.stateChanged}" id="datasetStateChangedVariable" />
                            <p:remoteCommand name="refreshAllLocksCommand" process="@this" update=":#{p:resolveClientId('datasetForm:pageRefreshFragment', view)},:messagePanel" actionListener="#{DatasetPage.refreshAllLocks()}"/>
                            <p:remoteCommand name="refreshAllCommand" process="@this" update=":datasetForm:topDatasetBlockFragment,:datasetForm:tabView:filesTable,:messagePanel" action="#{DatasetPage.refresh()}"/>
                            <!-- see the comment in the javascript below that explains what this button is for -->
                            <p:commandButton id="refreshButton" process="@this" widgetVar="refreshButton" update=":datasetForm:topDatasetBlockFragment,:datasetForm:tabView:filesTable" style="display:none"/>
                            <script>
                                //<![CDATA[
                                // javascript for refreshing page when locks
                                $(this).ready(function () {
                                    refreshIfStillLocked();
                                });
                            
                                var initialInterval = 5000; // 5 seconds
                                var maxInterval = 300000; // 5 minutes
                                var currentInterval = initialInterval;
                                var backoffFactor = 1.2; // Exponential factor
                                function refreshIfStillLocked() {
                                    if ($('input[id$="datasetLockedForAnyReasonVariable"]').val() === 'true') {
                                        // if dataset is locked, instruct the page to
                                        // wait and check again:
                                        waitAndCheckLockAgain();
                                    } else {
                                        // if not locked, has it just been unlocked?
                                        if ($('input[id$="datasetStateChangedVariable"]').val() === 'true') {
                                            // For whatever unknown PrimeFaces reason
                                            // the page needs to be refreshed twice, for all
                                            // the pull down menus to update properly:
                                            refreshAllCommand();
                                            // You can't just run 2 refreshAllCommand()s in a row
                                            // either; because the command has an "update=@all" on it,
                                            // so I guess if you try to execute the 2nd one right after
                                            // the first one, this fragment is still going to be loading -
                                            // so there would not yet be a command to run! (it needs to
                                            // be rendered, before you can execute it, that is)
                                            setTimeout(function () {
                                                // this button doesn't do anything, but it has an update="@all"
                                                // attribute:
                                                $('button[id$="refreshButton"]').trigger('click');
                                                //refreshAllCommand();
                                            }, 1500);
                                        } else {
                                          // Reset the interval if the dataset is unlocked
                                          currentInterval = initialInterval;
                                        }
                                    }
                                }
                            
                                function waitAndCheckLockAgain() {
                                    setTimeout(function () {
                                        // refresh the lock in the
                                        // backing bean; i.e., check, if the ingest has
                                        // already completed in the background:
                                        refreshAllLocksCommand();
                                        // Increase the interval exponentially for the next check
                                        currentInterval = Math.min((currentInterval * backoffFactor) + 2, maxInterval);
                                    }, currentInterval);
                                }
                                //]]>
                            </script>
                        </p:fragment>
                        <ui:fragment id="uploadFilesOnCreateTab" rendered="#{!deaccessioned and (DatasetPage.editMode == 'CREATE')}">
                            <ui:include src="editFilesFragment.xhtml">
                                <ui:param name="datasetPage" value="true"/>
                                <ui:param name="editDatafilesPage" value="false"/>
                                <ui:param name="rsyncSupported" value="#{DatasetPage.rsyncUploadSupported()}"/>
                                <ui:param name="globusUploadSupported" value="#{DatasetPage.globusUploadSupported()}"/>
                                <ui:param name="webloaderUploadSupported" value="#{DatasetPage.webloaderUploadSupported()}"/>
                                <ui:param name="dataverse" value="#{DatasetPage.dataset.owner}"/>
                                <ui:param name="dataset" value="#{DatasetPage.dataset}"/>
                                <ui:param name="version" value="#{version}"/>
                                <ui:param name="createDataset" value="true"/>
                            </ui:include>
                        </ui:fragment>
                        <p:tabView id="tabView" widgetVar="content" activeIndex="#{DatasetPage.selectedTabIndex}"
                                   rendered="#{empty DatasetPage.editMode or (DatasetPage.editMode == 'METADATA' or DatasetPage.editMode == 'LICENSE')}">
                            <p:ajax event="tabChange" listener="#{DatasetPage.tabChanged}" update="@this" />
                            <p:tab id="dataFilesTab" title="#{bundle.files}" 
                                   rendered="#{(!deaccessioned 
                                                or (deaccessioned and canUpdateDataset)) 
                                               and (empty DatasetPage.editMode)}">
                                <ui:include src="filesFragment.xhtml"/>
                            </p:tab>
                            <!-- 4.2.1: the 3 tabs below - metadata, terms and versions: these account for ~100 queries total -->
                            <!-- a lot of these however, are repeated queries on AuthenticatedUser and RoleAssignment; once these are optimized, the tabs will become very cheap. -->
                            <p:tab id="metadataMapTab" title="#{bundle['file.dataFilesTab.metadata.header']}"
                                   rendered="#{(!deaccessioned or (deaccessioned and canUpdateDataset)) 
                                               and (empty DatasetPage.editMode or DatasetPage.editMode == 'METADATA')}">
                                <div class="button-block tab-header margin-bottom text-right" jsf:rendered="#{empty DatasetPage.editMode}">
                                    <p:commandLink styleClass="btn btn-default btn-access" actionListener="#{DatasetPage.edit('METADATA')}" update="@form,:messagePanel" 
                                                   disabled="#{DatasetPage.lockedFromEdits or !DatasetPage.hasValidTermsOfAccess}" 
                                                   rendered="#{!widgetWrapper.widgetView 
                                                               and (sessionUserAuthenticated 
                                                               and empty DatasetPage.editMode and !widgetWrapper.widgetView
                                                               and canUpdateDataset)}"><!-- and !DatasetPage.dataset.deaccessioned -->
                                        <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0"/>
                                        <span class="glyphicon glyphicon-pencil"/> #{bundle['file.dataFilesTab.metadata.addBtn']}
                                    </p:commandLink>
                                    <div class="btn-group" jsf:rendered="#{DatasetPage.dataset.released 
                                                                           and (!DatasetPage.dataset.deaccessioned
                                                                           or (deaccessioned and canUpdateDataset))
                                                                           and !anonymizedAccess}">
                                        <button class="btn btn-default btn-export dropdown-toggle" type="button" data-toggle="dropdown">
                                            <span class="glyphicon glyphicon-export"/> #{bundle['dataset.exportBtn']} <span class="caret"></span>
                                        </button>
                                        <ul class="dropdown-menu pull-right text-left">
                                            <ui:repeat var="exporter" value="#{DatasetPage.exporters}">
                                                <li>
                                                    <h:outputLink value="#{exporter[1]}" target="_blank">
                                                        <h:outputText value="#{exporter[0]}"/>
                                                    </h:outputLink>
                                                </li>
                                            </ui:repeat>
                                        </ul>
                                    </div>
                                </div>
                                <ui:include src="metadataFragment.xhtml">
                                    <ui:param name="datasetPage" value="true"/>
                                    <ui:param name="template" value="#{DatasetPage.dataset.template}"/>
                                    <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? DatasetPage.editMode : ''}"/>
                                    <ui:param name="metadataBlocks" value="#{!empty DatasetPage.editMode ? DatasetPage.datasetVersionUI.metadataBlocksForEdit.entrySet().toArray(): DatasetPage.datasetVersionUI.metadataBlocksForView.entrySet().toArray()}"/>
                                    <ui:param name="publicationDate" value="#{DatasetPage.dataset.publicationDate != null ? DatasetPage.dataset.publicationDateFormattedYYYYMMDD : ''}"/>
                                    <ui:param name="citationDate" value="#{DatasetPage.dataset.citationDate != null ? DatasetPage.dataset.citationDateFormattedYYYYMMDD : ''}"/>
                                    <ui:param name="globalId" value="#{DatasetPage.dataset.globalId.asString()}"/>
                                    <ui:param name="altPID" value="#{DatasetPage.dataset.alternativePersistentIdentifier}"/>
                                    <ui:param name="mdLang" value="#{DatasetPage.getLocaleDisplayName(DatasetPage.effectiveMetadataLanguage)}"/>
                                    <ui:param name="mdLangCode" value="#{DatasetPage.effectiveMetadataLanguage}"/>
                                    <ui:param name="anonymized" value="#{anonymizedAccess}"/>
                                </ui:include>
                            </p:tab>
                            <!-- 4.2.1: see comment above -->
                            <p:tab id="termsTab" title="#{bundle['file.dataFilesTab.terms.header']}"
                                   rendered="#{!deaccessioned and (empty DatasetPage.editMode or DatasetPage.editMode == 'LICENSE')}">
                                <ui:include src="dataset-license-terms.xhtml">
                                    <ui:param name="editMode" value="#{!empty DatasetPage.editMode ? 'LICENSE': ''}"/>
                                    <ui:param name="termsOfUseAndAccess" value="#{version.termsOfUseAndAccess}"/>
                                    <ui:param name="datasetPage" value="true"/>
                                    <ui:param name="publicStore" value="DatasetPage.hasPublicStore"/>
                                </ui:include>
                            </p:tab>
                            <!-- 4.2.1: see above -->
                            <p:tab id="versionsTab" title="#{bundle['file.dataFilesTab.versions']}" rendered="#{empty DatasetPage.editMode}">
                                <ui:include src="dataset-versions.xhtml">
                                    <ui:param name="anonymized" value="#{anonymizedAccess}"/>
                                    <ui:param name="workingVersion" value="#{version}"/>
                                </ui:include>
                            </p:tab>
                        </p:tabView>
                    </div>
                    <!-- END View/Tabs infoMode -->
                    <!-- Create Metadata Tip -->
                    <div class="alert alert-info margin-top" jsf:rendered="#{DatasetPage.editMode == 'CREATE'}">
                        #{bundle['file.metadataTip']}
                    </div>
                    <!-- Create/Save Dataset Button Panel BTM editMode -->
                    <div class="button-block" jsf:rendered="#{!empty DatasetPage.editMode}">
                        <p:commandButton id="saveBottomTerms" styleClass="btn btn-default" rendered="#{DatasetPage.editMode == 'LICENSE'}"
                                         value="#{DatasetPage.editMode == 'CREATE' ? bundle['file.addBtn'] : bundle.saveChanges}" 
                                         onclick="testTOADatasetPage();" 
                                         oncomplete="$(document).scrollTop(0);"/>
                        <p:commandButton id="saveBottom" styleClass="btn btn-default" value="#{DatasetPage.editMode == 'CREATE' ? bundle['file.addBtn'] : bundle.saveChanges}" rendered="#{DatasetPage.editMode == 'CREATE' or DatasetPage.editMode == 'METADATA'}"
                                         onclick="PF('blockDatasetForm').show();"
                                         update=":datasetForm,:messagePanel"
                                         oncomplete="$(document).scrollTop(0);"
                                         action="#{DatasetPage.save}"
                                         />
                        <p:commandButton id="cancel" styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.cancel}" process="@this" update="@form" rendered="#{DatasetPage.editMode != 'CREATE'}">
                            <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="#{DatasetPage.editMode == 'METADATA' ? 1 : DatasetPage.selectedTabIndex}"/>
                        </p:commandButton>
                        <button id="cancelCreate" class="btn btn-link" value="#{bundle.cancel}" onclick="cancelDatasetCreate();return false;" jsf:rendered="#{DatasetPage.editMode == 'CREATE'}">#{bundle.cancel}</button>
                        <p:remoteCommand name="cancelCreateCommand" process="@this" partialSubmit="true" async="true" update="" action="#{DatasetPage.cancelCreate}" rendered="#{DatasetPage.editMode == 'CREATE'}"/>     
                    </div>
                    <!-- END: Create/Save Dataset Button Panel BTM editMode -->
                    <p:blockUI block="datasetForm" widgetVar="blockDatasetForm"/>
                    <!-- POPUPS -->
                    <ui:include src="file-edit-popup-fragment.xhtml">
                        <ui:param name="datasetVersion" value="#{version}"/>
                        <ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
                        <ui:param name="bean" value="#{DatasetPage}"/>
                        <ui:param name="restrictFileAction" value="restrictFiles"/>
                        <ui:param name="deleteFileAction" value="deleteFiles"/>
                        <ui:param name="saveEmbargoAction" value="saveEmbargo"/>
                        <ui:param name="saveRetentionAction" value="saveRetention"/>
                        <ui:param name="updateElements" value=":datasetForm:embargoInputs"/>
                        <ui:param name="updateRetentionElements" value=":datasetForm:retentionInputs"/>
                    </ui:include>
                    <p:dialog id="shareDialog" header="#{bundle['dataset.share.datasetShare']}" widgetVar="shareDialog" modal="true" rendered="#{!deaccessioned}">
                        <p class="help-block">#{bundle['dataset.share.datasetShare.tip']}</p>
                        <div id="sharrre-widget" data-url="#{dataverseSiteUrl}/dataset.xhtml?persistentId=#{dataset.globalId}" data-text="#{bundle['dataset.share.datasetShare.shareText']}"></div>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('shareDialog').hide()" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="configureToolDialog" styleClass="smallPopUp" header="#{DatasetPage.datasetConfigureTool.displayNameLang}" widgetVar="configureToolDialog" modal="true">
                        <p class="help-block">
                            <h:outputFormat value="#{DatasetPage.datasetConfigureTool.description}" escape="false"/>
                        </p>
                        <div class="button-block">
                            <p:commandLink styleClass="btn btn-default" action="#{DatasetPage.configure(DatasetPage.datasetConfigureTool)}" oncomplete="PF('configureToolDialog').hide();">
                                <h:outputFormat value="#{bundle['continue']}"/>
                            </p:commandLink>
                            <button class="btn btn-link" onclick="PF('configureToolDialog').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="citationsDialog" styleClass="smallPopUp" header="#{bundle['metrics.citations.dialog.header']}" widgetVar="citationsDialog" modal="true">
                        <p class="help-block">
                            <h:outputFormat value="#{bundle['metrics.citations.dialog.help']}" escape="false">
                                <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                <f:param value="#{systemConfig.guidesVersion}"/>
                            </h:outputFormat>
                        </p>
                        <div id="citations-list-block">
                            <div jsf:rendered="#{empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                #{bundle['metrics.citations.dialog.empty']}
                            </div>
                            <ui:fragment rendered="#{!empty datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}">
                                <ul>
                                    <ui:repeat value="#{datasetExternalCitationsServiceBean.getDatasetExternalCitationsByDataset(DatasetPage.dataset)}" var="citation">
                                        <li><a href="#{citation.citedByUrl}" target="_blank">#{citation.citedByUrl}</a></li>
                                    </ui:repeat>
                                </ul>
                            </ui:fragment>
                        </div>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('citationsDialog').hide()" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="downloadInvalid" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadInvalid" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noValidSelectedFilesForDownload']}</p>
                        <ui:fragment rendered="#{DatasetPage.dataset.fileAccessRequest}">
                            <p class="help-block">#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.requestAccessToRestrictedFilesWithEmbargo'] : bundle['dataset.requestAccessToRestrictedFiles']}</p>
                        </ui:fragment>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('downloadInvalid').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="transferInvalid" styleClass="smallPopUp" header="#{bundle['dataset.inValidSelectedFilesForTransfer']}" widgetVar="transferInvalid" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noValidSelectedFilesForTransfer']}</p>
                        <ui:fragment rendered="#{DatasetPage.dataset.fileAccessRequest}">
                            <p class="help-block">#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.requestAccessToRestrictedFilesWithEmbargo'] : bundle['dataset.requestAccessToRestrictedFiles']}</p>
                        </ui:fragment>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('transferInvalid').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="downloadTooLarge" styleClass="smallPopUp" header="#{bundle['file.zip.download.exceeds.limit.header']}" widgetVar="downloadTooLarge" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/>  #{bundle['file.zip.download.exceeds.limit.info']}</p>
  
                        <p class="help-block">
                            <h:outputFormat value="#{bundle['file.zip.download.exceeds.limit.detail']}" escape="false">
                                <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                <f:param value="#{systemConfig.guidesVersion}"/>
                                <f:param value="#{DatasetPage.zipDownloadLimitAsString}"/>
                            </h:outputFormat>
                        </p>

                    </p:dialog>
                    <p:dialog id="selectFilesForDownload" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForDownload" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForDownload']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForDownload').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="downloadMixed" styleClass="smallPopUp" header="#{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.inValidSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.inValidSelectedFilesForDownload']}" widgetVar="downloadMixed" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{DatasetPage.cantDownloadDueToEmbargoOrDVAccess ? bundle['dataset.mixedSelectedFilesForDownloadWithEmbargo'] : bundle['dataset.mixedSelectedFilesForDownload']}</p>
                        <table>
                            <ui:repeat var="resFile" value="#{DatasetPage.selectedNonDownloadableFiles}" >
                                <tr>
                                    <td>#{resFile.label}</td>
                                </tr>
                            </ui:repeat>
                        </table>
                        <div class="button-block">
                            <p class="help-block">#{bundle['dataset.downloadUnrestricted']}</p>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('downloadMixed').hide()" 
                                             rendered="#{!DatasetPage.guestbookAndTermsPopupRequired}"
                                             action="#{DatasetPage.startMultipleFileDownload()}"/>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('downloadMixed').hide();"
                                             rendered="#{DatasetPage.guestbookAndTermsPopupRequired and !settingsWrapper.rsyncDownload}"
                                             oncomplete="PF('guestbookAndTermsPopup').show();" />
                            <button class="btn btn-link" onclick="PF('downloadMixed').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="globusTransferMixed" styleClass="smallPopUp" header="#{bundle['dataset.inValidSelectedFilesForTransfer']}" widgetVar="globusTransferMixed" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.mixedSelectedFilesForTransfer']}</p>
                        <table>
                            <ui:repeat var="resFile" value="#{DatasetPage.selectedNonGlobusTransferableFiles}" >
                                <tr>
                                    <td>#{resFile.label}</td>
                                </tr>
                            </ui:repeat>
                        </table>
                        <div class="button-block">
                            <p class="help-block">#{bundle['dataset.transferUnrestricted']}</p>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('globusTransferMixed').hide()" 
                                             rendered="#{!DatasetPage.guestbookAndTermsPopupRequired}"
                                             action="#{DatasetPage.startGlobusTransfer(false, true)}"/>
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('globusTransferMixed').hide();"
                                             rendered="#{DatasetPage.guestbookAndTermsPopupRequired and !settingsWrapper.rsyncDownload}"
                                             oncomplete="PF('guestbookAndTermsPopup').show();" />
                            <button class="btn btn-link" onclick="PF('globusTransferMixed').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteDialog.header']}" widgetVar="deleteConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteDialog.tip']}</p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteConfirmation').hide()" action="#{DatasetPage.deleteDataset()}"/>
                            <button class="btn btn-link" onclick="PF('deleteConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteVersionConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteDraftDialog.header']}" widgetVar="deleteVersionConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteDraftDialog.tip']}</p>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}" onclick="PF('deleteVersionConfirmation').hide()" action="#{DatasetPage.deleteDatasetVersion()}"/>
                            <button class="btn btn-link" onclick="PF('deleteVersionConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="privateUrlId" styleClass="smallPopUp" header="#{bundle['dataset.privateurl.header']}" widgetVar="privateUrlConfirmation" modal="true">
                        <p:fragment id="privateUrlPanel" rendered="#{DatasetPage.userCanCreatePrivateURL}">
                            <p class="help-block">
                                <p>#{bundle['dataset.privateurl.introduction']}
                                #{bundle['dataset.privateurl.onlyone']}   </p>
                                <p>
                                <h:outputFormat value="#{bundle['dataset.privateurl.tip']}" escape="false">
                                    <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                    <f:param value="#{systemConfig.guidesVersion}"/>
                                </h:outputFormat>
                                </p>                                                                   
                            </p>
                            
                            <p>
                            <p>
                            <h:outputText   styleClass="highlightBold" value="#{bundle['dataset.privateurl.general.title']}"></h:outputText></p>   
                            <p>#{bundle['dataset.privateurl.general.description']}</p>     
                            <p:commandButton styleClass="btn btn-default" 
                                             value="#{bundle['dataset.privateurl.general.button.label']}" 
                                             action="#{DatasetPage.createPrivateUrl(false)}" update="privateUrlPanel,:messagePanel,disablePrivateUrlConfirmation" 
                                             disabled="#{(!empty(DatasetPage.privateUrl) and DatasetPage.anonymizedPrivateUrl)}"
                                             rendered="#{empty(DatasetPage.privateUrl)  or (!empty(DatasetPage.privateUrl) and DatasetPage.anonymizedPrivateUrl) }"/>    
                            <p:fragment rendered="#{!empty(DatasetPage.privateUrl) and !DatasetPage.anonymizedPrivateUrl}">
                            <div>
                                <div class="highlight" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" onclick="if (event.target) {
                                            selectText(event.target);
                                        } else {
                                            selectText(this);
                                        }">
                                   <ui:param name="privateUrlLink" value="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" />
                                    <p class="no-margin-bottom">
                                        <span>#{privateUrlLink}</span>
                                    </p>
                                </div>
                            </div>    
                            <div class="button-block">
                               <button class="btn btn-default btn-copy" data-clipboard-text="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" type="button">
                                    #{bundle['copyClipboard']}
                                </button>
                                <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disableGeneralPreviewUrl']}" action="#{DatasetPage.setPrivateUrlJustCreatedToFalse()}" oncomplete="PF('privateUrlConfirmation').hide();PF('disablePrivateUrlConfirmation').show()" rendered="#{!empty(DatasetPage.privateUrl)}" update="privateUrlPanel,:messagePanel,disablePrivateUrlConfirmation"/>
                            </div>
                            </p:fragment>    
                                
                            </p>
                            <p:fragment rendered="#{anonymizedAccessEnabled}">
                            <p>
                             <p>
                                 <h:outputText  styleClass="highlightBold" value="#{bundle['dataset.privateurl.anonymous.title']}"></h:outputText>
                                 <span class="glyphicon glyphicon-question-sign tooltip-icon"
                                       data-toggle="tooltip" data-placement="auto right" data-original-title="#{bundle['dataset.privateurl.anonymous.tooltip.preface']} #{DatasetPage.getAnonymizedFieldTypeNames()} "></span>
                             </p>   
                            <p>#{bundle['dataset.privateurl.anonymous.description']}</p>  
                            <p>#{bundle['dataset.privateurl.anonymous.description.paragraph.two']}</p>
                                 <h:outputFormat value="#{bundle['dataset.privateurl.anonymous.description.paragraph.three']}" escape="false">
                                    <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                    <f:param value="#{systemConfig.guidesVersion}"/>
                                </h:outputFormat>
                            <p>#{bundle['dataset.privateurl.createPrivateUrl.anonymized.unavailable']}</p>

                               
                            <p:commandButton styleClass="btn btn-default disabledTitle" 
                                             value="#{bundle['dataset.privateurl.anonymous.button.label']}" 
                                             action="#{DatasetPage.createPrivateUrl(true)}" 
                                             update="privateUrlPanel,:messagePanel" 
                                             rendered="#{anonymizedAccessEnabled and (empty(DatasetPage.privateUrl) or (!empty(DatasetPage.privateUrl) and !DatasetPage.anonymizedPrivateUrl))}" 
                                             disabled="#{DatasetPage.dataset.released or ((!empty(DatasetPage.privateUrl) and !DatasetPage.anonymizedPrivateUrl))}" 
                                             title="#{DatasetPage.dataset.released ? bundle['dataset.privateurl.createPrivateUrl.anonymized.unavailable']:'' }"/>
                                  
                            </p>
                            <p:fragment rendered="#{!empty(DatasetPage.privateUrl) and DatasetPage.anonymizedPrivateUrl}">
                             <div>
                                <div class="highlight" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" onclick="if (event.target) {
                                            selectText(event.target);
                                        } else {
                                            selectText(this);
                                        }">
                                   <ui:param name="privateUrlLink" value="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" />
                                    <p class="no-margin-bottom">
                                        <span>#{privateUrlLink}</span>
                                    </p>
                                </div>
                            </div>    
                            <div class="button-block">
                               <button class="btn btn-default btn-copy" data-clipboard-text="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" type="button">
                                    #{bundle['copyClipboard']}
                                </button>
                                <p:commandButton styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disableAnonPreviewUrl']}" action="#{DatasetPage.setPrivateUrlJustCreatedToFalse()}" oncomplete="PF('privateUrlConfirmation').hide();PF('disablePrivateUrlConfirmation').show()" rendered="#{!empty(DatasetPage.privateUrl)}" update="privateUrlPanel,:messagePanel,disablePrivateUrlConfirmation"/>
                            </div>    
                            </p:fragment>
                            <ui:remove>   
                            <div>
                                <div class="highlight" jsf:rendered="#{empty(DatasetPage.privateUrl)}">
                                    <p class="no-margin-bottom">#{bundle['dataset.privateurl.absent']}</p>
                                </div>
                                <div class="highlight" jsf:rendered="#{!empty(DatasetPage.privateUrl)}" onclick="if (event.target) {
                                            selectText(event.target);
                                        } else {
                                            selectText(this);
                                        }">
                                    <p class="highlight" jsf:rendered="#{DatasetPage.anonymizedPrivateUrl}">#{bundle['dataset.privateurl.anonymized']}</p>
                                    <p class="highlight" jsf:rendered="#{!DatasetPage.anonymizedPrivateUrl}">#{bundle['dataset.privateurl.full']}</p>
                                    <ui:param name="privateUrlLink" value="#{DatasetPage.getPrivateUrlLink(DatasetPage.privateUrl)}" />
                                    <p class="no-margin-bottom">
                                        <span>#{privateUrlLink}</span>
                                    </p>
                                </div>
                            </div>
                            </ui:remove>    
                        </p:fragment>
                            <button class="btn btn-link" onclick="PF('privateUrlConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.close}
                            </button> 
                        </p:fragment>
                        <p:fragment id="privateUrlPanelCannotCreate" rendered="#{!DatasetPage.userCanCreatePrivateURL}">
                            <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.privateurl.cannotCreate']}</p>
                            <div class="button-block">
                                <button class="btn btn-link" onclick="PF('privateUrlConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.cancel}
                                </button>
                            </div>
                        </p:fragment>
                    </p:dialog>
                    <p:dialog id="disablePrivateUrlConfirmation" styleClass="smallPopUp" header="#{bundle['dataset.privateurl.header']}" widgetVar="disablePrivateUrlConfirmation" modal="true" closable="false">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.privateurl.disableConfirmationText']}</p>
                        <div class="button-block">
                            
                            <p:commandButton rendered="#{DatasetPage.anonymizedPrivateUrl}" styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disableAnonPreviewUrlConfirm']}" action="#{DatasetPage.disablePrivateUrl()}" update="privateUrlPanel,:messagePanel" onclick="PF('disablePrivateUrlConfirmation').hide();"/>
                            <p:commandButton rendered="#{!DatasetPage.anonymizedPrivateUrl}" styleClass="btn btn-default" value="#{bundle['dataset.privateurl.disableGeneralPreviewUrlConfirm']}" action="#{DatasetPage.disablePrivateUrl()}" update="privateUrlPanel,:messagePanel" onclick="PF('disablePrivateUrlConfirmation').hide();"/>

                            <button class="btn btn-link" onclick="PF('disablePrivateUrlConfirmation').hide();PF('privateUrlConfirmation').show();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deleteSelectedFileConfirmation" styleClass="smallPopUp" header="#{bundle['file.deleteFileDialog.header']}" widgetVar="deleteSelectedFileConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteFileDialog.multiple.immediate']}</p>
                        <ui:fragment rendered="#{DatasetPage.dataset.released}">
                            <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deleteFileDialog.failed.tip']}</p>
                        </ui:fragment>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle['file.delete']}" onclick="PF('deleteSelectedFileConfirmation').hide()"
                                             action="#{DatasetPage.deleteFilesAndSave()}" />
                            <button class="btn btn-link" onclick="PF('deleteSelectedFileConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="computeInvalid" styleClass="smallPopUp" header="#{bundle['dataset.compute.computeBtn']}" widgetVar="computeInvalid" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.compute.computeBatchRestricted']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('computeInvalid').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:fragment>
                        <p:autoUpdate />
                        <p:outputPanel>
                            <p:dialog id="deaccessionBlock" rendered="#{DatasetPage.renderDeaccessionPopup}" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionBlock" modal="true" visible="#{facesContext.validationFailed}">
                                <p:focus for="selectVersionChk"/>
                                <div class="alert alert-warning">
                                    <span class="glyphicon glyphicon-warning-sign">&#160;</span><h:outputFormat value="#{bundle['file.deaccessionDialog.tip.permanent']}" escape="false" />
                                    <p><br/>
                                        <h:outputFormat value="#{bundle['file.deaccessionDialog.tip']}" escape="false" />
                                    </p>
                                </div>
                                <div class="form-group" jsf:rendered="#{DatasetPage.releasedVersionTabList.size() > 1}">
                                    <label for="selectVersionChk">#{bundle['file.deaccessionDialog.reason.question1']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/></label>
                                    <p:selectManyCheckbox id="selectVersionChk" value="#{DatasetPage.selectedDeaccessionVersions}" converter="datasetVersionConverter"
                                                          layout="pageDirection" required="#{param['DO_DEACCESSION_VALIDATION']}" requiredMessage="#{bundle['file.deaccessionDialog.dialog.selectVersion.error']}" widgetVar="selectVersionChk">
                                        <f:selectItems value="#{DatasetPage.releasedVersionTabList}" var="versionTab" itemLabel="#{bundle['file.deaccessionDialog.version']} #{versionTab.versionNumber}.#{versionTab.minorVersionNumber}, #{versionTab.versionDate}"  itemValue="#{versionTab}" />
                                    </p:selectManyCheckbox>
                                    <p:message for="selectVersionChk"/>
                                </div>
                                <div class="form-group">
                                    <label for="reasonOptions">#{bundle['file.deaccessionDialog.reason.question2']} <span class="glyphicon glyphicon-asterisk text-danger" title="#{bundle.requiredField}"/></label>
                                    <p:selectOneMenu widgetVar="reasonOptions" id="reasonOptions" styleClass="form-control" value="#{DatasetPage.deaccessionReasonRadio}" required="#{param['DO_DEACCESSION_VALIDATION']}" 
                                                     binding="#{reasonRadio}" requiredMessage="#{bundle['file.deaccessionDialog.dialog.reason.error']}">
                                        <f:selectItem itemLabel="#{bundle.select}" itemValue="#{null}" noSelectionOption="true" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.identifiable']}" itemValue="1" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.beRetracted']}" itemValue="2" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.beTransferred']}" itemValue="3" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.IRB']}" itemValue="4" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.legalIssue']}" itemValue="5" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.notValid']}" itemValue="6" />
                                        <f:selectItem itemLabel="#{bundle['file.deaccessionDialog.reason.selectItem.other']}" itemValue="7" />
                                    </p:selectOneMenu>
                                    <p:message for="reasonOptions"/>
                                </div>
                                <div class="form-group">
                                    <label for="reasonForDeaccession">
                                        #{bundle['file.deaccessionDialog.enterInfo']}
                                    </label>
                                    <p:inputTextarea id="reasonForDeaccession" styleClass="form-control" autoResize="false" rows="2" cols="40" title="#{bundle['file.deaccessionDialog.enterInfo']}"
                                                     value="#{DatasetPage.deaccessionReasonText}" widgetVar="reasonForDeaccession" validator="#{DatasetPage.validateDeaccessionReason}">
                                        <f:attribute name="reasonRadio" value="#{reasonRadio}" />
                                    </p:inputTextarea>
                                    <p:message for="reasonForDeaccession"/>
                                </div>
                                <div class="form-group">
                                    <label for="forwardURLForDeaccession">
                                        #{bundle['file.deaccessionDialog.leaveURL']}
                                    </label>
                                    <p:inputText id="forwardURLForDeaccession" styleClass="form-control" value="#{DatasetPage.deaccessionForwardURLFor}" widgetVar="forwardURLForDeaccession"
                                                 validator="#{DatasetPage.validateForwardURL}"/>
                                    <p:message for="forwardURLForDeaccession"/>
                                    <p:watermark for="forwardURLForDeaccession" value="#{bundle['file.deaccessionDialog.leaveURL.watermark']}" id="watermark" />
                                </div>
                                <div class="button-block">
                                    <p:commandButton styleClass="btn btn-default" value="#{bundle.deaccession}"  
                                                     oncomplete="if (args &amp;&amp; !args.validationFailed) PF('deaccessionConfirmation').show();">
                                        <f:param name="DO_DEACCESSION_VALIDATION" value="true"/>
                                    </p:commandButton>
                                    <p:commandButton styleClass="btn btn-link" value="#{bundle.cancel}" action="#{DatasetPage.setRenderDeaccessionPopup(false)}" onclick="PF('deaccessionBlock').hide();PF('blockDatasetForm').hide();" immediate="true"/>
                                </div>
                            </p:dialog>
                        </p:outputPanel>
                    </p:fragment>
                    <p:dialog id="deaccessionConfirmation" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deaccessionDialog.deaccession.tip']}</p>
                        <div class="button-block">
                            <h:commandButton styleClass="btn btn-default" value="#{bundle.yes}" onclick="PF('deaccessionConfirmation').hide();
                                    PF('deaccessionBlock').hide()" action="#{DatasetPage.deaccessionVersions}" />
                            <button class="btn btn-link" onclick="PF('deaccessionConfirmation').hide();" type="button">
                                #{bundle.no}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="deaccessionAllConfirmation" header="#{bundle['dataset.editBtn.itemLabel.deaccession']}" widgetVar="deaccessionAllConfirmation" modal="true">
                        <p class="text-warning"><span class="glyphicon glyphicon-warning-sign"/> #{bundle['file.deaccessionDialog.deaccessionDataset.tip']}</p>
                        <div class="button-block">
                            <h:commandButton styleClass="btn btn-default" value="#{bundle.yes}" 
                                             onclick="PF('deaccessionAllConfirmation').hide();PF('deaccessionBlock').hide();PF('blockDatasetForm').hide();" 
                                             action="#{DatasetPage.deaccessionVersions}"/>
                            <button class="btn btn-link" onclick="PF('deaccessionAllConfirmation').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.no}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="compareTwo" header="#{bundle['file.viewDiffDialog.header']}" widgetVar="compareTwo" modal="true">
                        <p class="help-block"><span class="glyphicon glyphicon-exclamation-sign text-danger"/> <span class="text-danger">#{bundle['file.viewDiffDialog.dialog.warning']}</span></p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('compareTwo').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="detailsBlocks" styleClass="largePopUp" header="#{bundle['file.viewDiffDialog.header']}" widgetVar="detailsBlocks" modal="true">
                        <div id="version-title" class="margin-bottom-half">#{DatasetPage.datasetVersionDifference.newVersion.title}</div>
                        <div id="version-details-block" class=" clearfix margin-bottom-half">
                            <div class="pull-left">
                                &#160;
                            </div>
                            <div class="pull-left">
                                #{bundle['file.viewDiffDialog.version']}: #{DatasetPage.datasetVersionDifference.originalVersion.semanticVersion}<br/>
                                #{bundle['file.viewDiffDialog.lastUpdated']}: #{DatasetPage.datasetVersionDifference.originalVersion.localeLastUpdateTime}<br/>
                                <p:fragment rendered="#{versionNoteEnabled}">#{bundle['file.viewDiffDialog.versionNote']}: #{DatasetPage.datasetVersionDifference.originalVersion.versionNote}</p:fragment>
                            </div>
                            <div class="pull-left">
                                #{bundle['file.viewDiffDialog.version']}: #{DatasetPage.datasetVersionDifference.newVersion.semanticVersion}<br/>
                                #{bundle['file.viewDiffDialog.lastUpdated']}: #{DatasetPage.datasetVersionDifference.newVersion.localeLastUpdateTime}<br/>
                                <p:fragment rendered="#{versionNoteEnabled}">#{bundle['file.viewDiffDialog.versionNote']}: #{DatasetPage.datasetVersionDifference.newVersion.versionNote}</p:fragment>
                            </div>
                        </div>
                        <ui:fragment rendered="#{!empty(DatasetPage.datasetVersionDifference.detailDataByBlock)}">
                            <ui:repeat value="#{DatasetPage.datasetVersionDifference.detailDataByBlock}" var="block">
                                <div class="panel panel-default">
                                    <div class="panel-heading text-info">
                                        <h:outputText value="#{block.get(0)[0].datasetFieldType.metadataBlock.localeDisplayName}" />
                                    </div>
                                    <p:dataTable id="byBlockInner" styleClass="dvnDifferanceTable" var="dsfArray" value="#{block}">
                                        <p:column styleClass="versionValue">
                                            <h:outputText value="#{dsfArray[0].datasetFieldType.localeTitle}" />
                                        </p:column>
                                        <p:column styleClass="versionDetails">
                                            <h:outputText rendered="#{dsfArray[0].datasetFieldType.primitive and !(dsfArray[0].isEmpty())}" value="#{dsfArray[0].displayValue}" />
                                            <h:outputText rendered="#{!dsfArray[0].datasetFieldType.primitive and !(dsfArray[0].isEmpty())}" value="#{dsfArray[0].compoundDisplayValue}" />
                                        </p:column>
                                        <p:column styleClass="versionDetails" >
                                            <h:outputText rendered="#{dsfArray[1].datasetFieldType.primitive and !(dsfArray[1].isEmpty())}" value="#{dsfArray[1].displayValue}" />
                                            <h:outputText rendered="#{!dsfArray[1].datasetFieldType.primitive and !(dsfArray[1].isEmpty())}" value="#{dsfArray[1].compoundDisplayValue}" />
                                        </p:column>
                                    </p:dataTable>
                                </div>
                            </ui:repeat>
                        </ui:fragment>
                        <div class="panel panel-default" jsf:rendered="#{!empty(DatasetPage.datasetVersionDifference.fileNote)}">
                            <div class="panel-heading text-info" jsf:rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesDiffList)}">
                                <h:outputText id="outputTextAddedRemoved" value="#{bundle['file.viewDiffDialog.files.header']}"/>
                            </div>
                            <p:dataTable id="diffFilesDataTable" styleClass="dvnDifferanceTable"  value="#{DatasetPage.datasetVersionDifference.datasetFilesDiffList}" var="fileDiff"
                                         rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesDiffList)}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']} #{fileDiff.fileId}"/>
                                    <div class="checksum-block">
                                        <h:outputText value="#{fileDiff.fileChecksumType} #{fileDiff.fileChecksumValue}"/>
                                    </div>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileDiff.file1Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileDiff.fileName1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileName1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileDiff.fileType1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileType1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileDiff.fileSize1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileSize1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileDiff.fileCat1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileCat1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileDiff.fileDesc1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileDesc1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileDiff.fileProvFree1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileProvFree1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileAccess']}: #{fileDiff.fileRest1}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileRest1 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileDiff.file1Empty}">
                                    &#160;
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileDiff.file2Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileDiff.fileName2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileName2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileDiff.fileType2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileType2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileDiff.fileSize2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileSize2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileDiff.fileCat2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileCat2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileDiff.fileDesc2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileDesc2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileDiff.fileProvFree2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileProvFree2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileAccess']}: #{fileDiff.fileRest2}" styleClass="diffDetailBlock" rendered="#{fileDiff.fileRest2 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileDiff.file2Empty}">
                                    &#160;
                                </p:column>
                            </p:dataTable>
                            <p:dataTable id="replacemetFilesDataTable" style="border-top:1px solid #ddd;" styleClass="dvnDifferanceTable" value="#{DatasetPage.datasetVersionDifference.datasetFilesReplacementList}" var="fileReplace"
                                         rendered="#{!empty(DatasetPage.datasetVersionDifference.datasetFilesReplacementList)}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileReplaced']}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileReplace.fdi.file1Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']}: #{fileReplace.file1Id}" styleClass="diffDetailBlock" rendered="#{fileReplace.file1Id != null}"/>
                                    <h:outputText value="#{fileReplace.file1ChecksumType}: #{fileReplace.file1ChecksumValue}" styleClass="diffDetailBlock" rendered="#{fileReplace.file1Id != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileReplace.fdi.fileName1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileName1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileReplace.fdi.fileType1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileType1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileReplace.fdi.fileSize1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileSize1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileReplace.fdi.fileCat1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileCat1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileReplace.fdi.fileDesc1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileDesc1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileReplace.fdi.fileProvFree1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileProvFree1 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileAccess']}: #{fileReplace.fdi.fileRest1}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileRest1 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileReplace.fdi.file1Empty}">
                                    &#160;
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{! fileReplace.fdi.file2Empty}">
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileID']}: #{fileReplace.file2Id}" styleClass="diffDetailBlock" rendered="#{fileReplace.file2Id != null}"/>
                                    <h:outputText value="#{fileReplace.file2ChecksumType}: #{fileReplace.file2ChecksumValue}" styleClass="diffDetailBlock" rendered="#{fileReplace.file2Id != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileName']}: #{fileReplace.fdi.fileName2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileName2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileType']}: #{fileReplace.fdi.fileType2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileType2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileSize']}: #{fileReplace.fdi.fileSize2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileSize2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.category']}: #{fileReplace.fdi.fileCat2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileCat2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.description']}: #{fileReplace.fdi.fileDesc2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileDesc2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.provDescription']}: #{fileReplace.fdi.fileProvFree2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileProvFree2 != null}"/>
                                    <h:outputText value="#{bundle['file.viewDiffDialog.fileAccess']}: #{fileReplace.fdi.fileRest2}" styleClass="diffDetailBlock" rendered="#{fileReplace.fdi.fileRest2 != null}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" rendered="#{fileReplace.fdi.file2Empty}">
                                    &#160;
                                </p:column>
                            </p:dataTable>
                        </div>
                        <div class="panel panel-default" jsf:rendered="#{!empty(DatasetPage.datasetVersionDifference.changedTermsAccess)}">
                            <div class="panel-heading text-info">
                                <h:outputText id="outputTextTOU" value="#{bundle['dataset.versionDifferences.termsOfUseAccess']}"/>
                            </div>
                            <p:dataTable id="changedTermsAccessTable" styleClass="dvnDifferanceTable" var="diffArray" value="#{DatasetPage.datasetVersionDifference.changedTermsAccess}">
                                <p:column styleClass="versionValue">
                                    <h:outputText value="#{diffArray[0]}"/>
                                </p:column>
                                <p:column styleClass="versionDetails">
                                    <h:outputText value="#{diffArray[1]}"/>
                                </p:column>
                                <p:column styleClass="versionDetails" >
                                    <h:outputText value="#{diffArray[2]}"/>
                                </p:column>
                            </p:dataTable>
                        </div>
                        <div class="button-block margin-bottom">
                            <button class="btn btn-default" onclick="PF('detailsBlocks').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.done}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="selectFilesForRequestAccess" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectFilesForRequestAccess" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.noSelectedFilesForRequestAccess']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectFilesForRequestAccess').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="selectEmbargoedFilesForRequestAccess" styleClass="smallPopUp"
                              header="#{bundle['dataset.noSelectedFiles.header']}" widgetVar="selectEmbargoedFilesForRequestAccess" modal="true">
                        <p class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"/> #{bundle['dataset.embargoedSelectedFilesForRequestAccess']}</p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('selectEmbargoedFilesForRequestAccess').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="fileTagsPopup" styleClass="smallPopUp" header="#{bundle['file.editTags']}" widgetVar="fileTagsPopup" modal="true">
                        <p:focus for="fileTagsMenuDS"/>
                        <p class="help-block">#{bundle['file.editTagsDialog.tip']}</p>
                        <div class="form-horizontal" jsf:rendered="#{!(empty DatasetPage.selectedFiles)}">
                            <div class="form-group text-left">
                                <label for="selectedTagsList" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.selectedTags']}
                                </label>
                                <div class="col-sm-8">
                                    <p:outputPanel id="selectedTagsList" style="padding-top:.5em;">
                                        <h:outputText value="#{bundle['file.editTagsDialog.selectedTags.none']}" rendered="#{(empty DatasetPage.selectedTags) and (empty DatasetPage.selectedTabFileTags)}" />

                                        <ui:repeat value="#{DatasetPage.selectedTags}" var="tags" rendered="#{!empty DatasetPage.selectedTags}">
                                            <h:outputText value="#{tags}" styleClass="label label-default" style="margin-right:.5em;display:inline-block;"/>
                                        </ui:repeat>
                                        <ui:repeat value="#{DatasetPage.selectedTabFileTags}" var="tags" rendered="#{!empty DatasetPage.selectedTabFileTags}">
                                            <h:outputText value="#{tags}" styleClass="label label-info" style="margin-right:.5em;display:inline-block;"/>
                                        </ui:repeat>
                                    </p:outputPanel>
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label for="fileTagsMenuDS" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.select']}
                                </label>
                                <div class="col-sm-8">
                                    <p:selectCheckboxMenu id="fileTagsMenuDS" styleClass="form-control"
                                                          value="#{DatasetPage.selectedTags}" label="#{bundle.select}">
                                        <p:ajax event="toggleSelect" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <p:ajax event="change" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <f:selectItems value="#{DatasetPage.categoriesByName}"/>
                                    </p:selectCheckboxMenu>
                                    <p:message for="fileTagsMenuDS" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label for="fileTagAddNewDS" class="col-sm-4 control-label">
                                    #{bundle['file.editTagsDialog.add']}
                                </label>
                                <div class="col-sm-8">
                                    <div class="row form-inline">
                                        <div class="col-sm-12">
                                            <p class="help-block">#{bundle['file.editTagsDialog.add.tip']}</p>
                                            <p:inputText id="fileTagAddNewDS" styleClass="form-control"
                                                         type="text" value="#{DatasetPage.newCategoryName}"
                                                         placeholder="#{bundle['file.editTagsDialog.newName']}"
                                                         onkeypress="if (event.keyCode == 13) {
                                                                     return false;
                                                                 }"/>
                                            <p:commandButton styleClass="btn btn-default" style="margin-left:.5em;" value="#{bundle.apply}" action="#{DatasetPage.saveNewCategory}" update="selectedTagsList, fileTagAddNewDS, fileTagsMenuDS"/>
                                        </div>
                                    </div>
                                    <p:message for="fileTagAddNewDS" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left" jsf:rendered="#{DatasetPage.tabularDataSelected}">
                                <label for="tabularDataTagsDSPage" class="col-sm-4 control-label">
                                    #{bundle['file.tabularDataTags']}
                                </label>
                                <div class="col-sm-8">
                                    <p class="help-block">#{bundle['file.tabularDataTags.tip']}</p>
                                    <p:selectCheckboxMenu id="tabularDataTagsDSPage" styleClass="form-control"
                                                          value="#{DatasetPage.selectedTabFileTags}" label="#{bundle.select}"
                                                          filter="false">
                                        <p:ajax event="toggleSelect" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <p:ajax event="change" listener="#{DatasetPage.handleSelection}" update="selectedTagsList" />
                                        <f:selectItems value="#{DatasetPage.tabFileTags}" />
                                    </p:selectCheckboxMenu>
                                    <p:message for="tabularDataTagsDSPage" display="text" />
                                </div>
                            </div>
                            <div class="form-group text-left">
                                <label class="col-sm-4 control-label">
                                    #{bundle['dataset.removeUnusedFileTags.label']}
                                </label>
                                <div class="col-sm-8">
                                    <p class="help-block">#{bundle['dataset.removeUnusedFileTags.tip']}</p>
                                    <p:selectBooleanCheckbox id="removeUnused" itemLabel="#{bundle['dataset.removeUnusedFileTags.check']}" value="#{DatasetPage.removeUnusedTags}" widgetVar="removeUnused"/>
                                </div>
                            </div>
                        </div>
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" id="fileTagsPopupSaveButton" value="#{bundle.saveChanges}" oncomplete="PF('fileTagsPopup').hide()" update=":datasetForm:tabView:filesTable, :datasetForm" action="#{DatasetPage.saveFileTagsAndCategories()}"/>
                            <p:commandButton styleClass="btn btn-link" id="fileTagsPopupCancelButton" value="#{bundle.cancel}" onclick="PF('fileTagsPopup').hide();
                                    PF('blockDatasetForm').hide();" actionListener="#{DatasetPage.clearFileMetadataSelectedForTagsPopup()}"/>
                        </div>
                    </p:dialog>
                    
                    <!-- Request Access Sign Up/Log In Button -->
                    <p:dialog id="accessSignUpLogIn" header="#{bundle['file.requestAccess']}" widgetVar="accessSignUpLogIn_popup" modal="true">
                        <p class="help-block">
                            <span class="glyphicon glyphicon-warning-sign text-danger"/>&#160;
                            <h:outputFormat styleClass="text-danger" value="#{dataverseHeaderFragment.signupAllowed ? bundle['file.requestAccess.dialog.msg.signup'] : bundle['file.requestAccess.dialog.msg']}" escape="false">
                                <f:param value="#{navigationWrapper.redirectPage}"/>
                                <f:param value="#{dataverseHeaderFragment.getSignupUrl(navigationWrapper.redirectPage)}"/>
                                <f:param value="#{widgetWrapper.widgetView ? '_blank' : '_self'}"/>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('accessSignUpLogIn_popup').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <!-- END: Request Access Sign Up/Log In Button -->
                    <p:dialog id="guestbookAndTermsPopup" styleClass="largePopUp" header="#{bundle['file.downloadDialog.header']}" widgetVar="guestbookAndTermsPopup" modal="true">
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                        <ui:include src="guestbook-terms-popup-fragment.xhtml">
                            <ui:param name="popupContext" value="downloadDataset"/>
                            <ui:param name="workingVersion" value="#{version}"/>
                            <ui:param name="guestbookAndTermsPopupRequired" value="#{DatasetPage.guestbookAndTermsPopupRequired}"/>
                            <ui:param name="guestbookPopupRequired" value="#{DatasetPage.guestbookPopupRequired}"/>
                            <ui:param name="fileMetadataForAction" value="#{DatasetPage.fileMetadataForAction}"/>
                            <ui:param name="hasRestrictedFile" value="#{DatasetPage.downloadingRestrictedFiles()}"/>
                            <ui:param name="guestbookResponse" value="#{DatasetPage.guestbookResponse}" rendered="#{!settingsWrapper.rsyncDownload}"/>
                            <ui:param name="fileDownloadHelper" value="#{DatasetPage.fileDownloadHelper}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                            <ui:param name="termsGuestbookPopupAction" value="#{DatasetPage.termsGuestbookPopupAction}"/>
                            <ui:param name="guestbookPopupRequiredAtDownload" value="#{DatasetPage.guestbookPopupRequiredAtDownload}"/>
                            <ui:param name="isGlobusTransfer" value="#{DatasetPage.globusTransferRequested}"/>
                        </ui:include>
                    </p:dialog>
                    <!-- Preview Guestbook -->
                    <p:dialog id="previewGuestbook" styleClass="largePopUp" header="#{bundle['dataset.manageGuestbooks.tab.action.btn.view.dialog.header']}" widgetVar="viewGuestbook" modal="true">
                        <ui:include src="guestbook-preview-popup-fragment.xhtml">
                            <ui:param name="selectedGuestbook" value="#{DatasetPage.selectedGuestbook}"/>
                            <ui:param name="enableEdit" value="false"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="rsyncDataAccessPopup" styleClass="smallPopUp" header="#{bundle['file.dataFilesTab.dataAccess']}" widgetVar="rsyncDataAccessPopup" modal="true"
                              rendered="#{fileMetadata.dataFile.filePackage and systemConfig.rsyncDownload 
                                          and !version.getDataset().getStorageIdentifier().startsWith('s3://')}">
                        <!-- Data Access for Rsync Download -->
                        <ui:include src="file-data-access-fragment.xhtml">
                            <ui:param name="fileMetadata" value="#{fileMetadata}"/>
                            <ui:param name="datasetVersion" value="#{version}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                        </ui:include>
                        <button class="btn btn-default" onclick="PF('rsyncDataAccessPopup').hide();">
                            #{bundle.done}
                        </button>
                    </p:dialog>
                    <p:dialog id="downloadPackagePopup" styleClass="smallPopUp" header="#{bundle['packageDownload.title']}" widgetVar="downloadPackagePopup" modal="true">
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.MarkupChecker" />
                        <ui:include src="package-download-popup-fragment.xhtml">
                            <ui:param name="workingVersion" value="#{version}"/>
                            <ui:param name="guestbookAndTermsPopupRequired" value="#{DatasetPage.guestbookAndTermsPopupRequired}"/>
                            <ui:param name="guestbookResponse" value="#{DatasetPage.guestbookResponse}" rendered="#{!settingsWrapper.rsyncDownload}"/>
                            <ui:param name="fileDownloadService" value="#{DatasetPage.fileDownloadService}"/>
                        </ui:include>
                    </p:dialog>
                    <p:dialog id="linkDatasetForm" styleClass="largePopUp" header="#{bundle['dataset.link.title']}" widgetVar="linkDatasetForm" modal="true" rendered="#{DatasetPage.showLinkingPopup}">
                        <p:focus for="dataverseLinkName"/>
                        <div class="form-horizontal">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['dataverse.link.dataset.choose']}" escape="false">
                                    <o:param>
                                        <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('linkDatasetForm').hide();PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                        </p:commandLink>
                                    </o:param>
                                </h:outputFormat>
                            </p>
                            <div class="form-group">
                                <label class="col-xs-3 control-label">
                                    <h:outputText value="#{bundle['dataverse.link.yourDataverses']}"/>
                                </label>
                                <div class="col-xs-8">
                                    <p:fragment id="linkNameContent">
                                        <p:autoComplete id="dataverseLinkName"
                                                        placeholder="#{bundle['dataverse.link.yourDataverses.inputPlaceholder']}"
                                                        emptyMessage="#{bundle['dataverse.link.dataset.none']}"
                                                        scrollHeight="180" forceSelection="true" 
                                                        minQueryLength="1" queryDelay="1000"
                                                        value="#{DatasetPage.selectedDataverseForLinking}" 
                                                        multiple="false"
                                                        completeMethod="#{DatasetPage.completeLinkingDataverse}"
                                                        required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
                                                        styleClass="DropdownPopup" panelStyleClass="DropdownPopupPanel"
                                                        var="dataverseLk" itemLabel="#{dataverseLk.displayName}" itemValue="#{dataverseLk}" converter="dataverseConverter">
                                            <p:column>
                                                <h:outputText value="#{dataverseLk.displayName}"/>
                                            </p:column>
                                            <p:column>
                                                <h:outputText value="#{dataverseLk.alias}"/>
                                            </p:column>
                                            <p:ajax process="@this" event="itemSelect" />
                                            <p:ajax process="@this" event="itemUnselect" />
                                        </p:autoComplete>
                                        <p:message for="dataverseLinkName"/>
                                    </p:fragment>
                                </div>
                            </div>
                        </div>
                        <div>
                            <p:fragment rendered="#{!empty DatasetPage.alreadyLinkedDataverses}"> 
                            <h:outputLabel  value="#{bundle['dataset.linking.popop.already.linked.note']}"/>&#160;
                            <h:outputText rendered="#{!empty DatasetPage.alreadyLinkedDataverses }" value="#{DatasetPage.alreadyLinkedDataverses}"/>
                            </p:fragment>
                        </div>
                        <div class="button-block">
                            <p:commandButton id="saveLinkButton" styleClass="btn btn-default"    
                                             update="linkNameContent @([id$=Messages])" 
                                             oncomplete="if (args &amp;&amp; !args.validationFailed) linkDatasetCommand();"
                                             value="#{bundle['dataset.link.save']}">
                                <f:param name="DO_DS_LINK_VALIDATION" value="true"/>
                            </p:commandButton>
                            <button class="btn btn-link" onclick="PF('linkDatasetForm').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:remoteCommand name="linkDatasetCommand" oncomplete="PF('linkDatasetForm').hide();" update=":messagePanel  @([id$=Messages])" actionListener="#{DatasetPage.saveLinkingDataverses}"/>
                    <p:dialog id="unlinkDatasetForm" styleClass="largePopUp" header="#{bundle['dataset.unlink.title']}" widgetVar="unlinkDatasetForm" modal="true" rendered="#{DatasetPage.showUnLinkingPopup}">
                        <p:focus for="dataverseUnLinkName"/>
                        <div class="form-horizontal">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['dataverse.unlink.dataset.choose']}" escape="false">
                                    <o:param>
                                        <p:commandLink value="#{settingsWrapper.supportTeamName}" oncomplete="PF('unlinkDatasetForm').hide();PF('contactForm').show()" update=":contactDialog" actionListener="#{sendFeedbackDialog.initUserInput}">
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.messageSubject}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.recipient}" value="#{null}"/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userMessage}" value=""/>
                                            <f:setPropertyActionListener target="#{sendFeedbackDialog.userEmail}" value=""/>
                                        </p:commandLink>
                                    </o:param>
                                </h:outputFormat>
                            </p>
                            <div class="form-group">
                                <label class="col-xs-3 control-label">
                                    <h:outputText value="#{bundle['dataverse.link.yourDataverses']}"/>
                                </label>
                                <div class="col-xs-8">
                                    <p:fragment id="unlinkNameContent">
                                        <p:autoComplete id="dataverseUnLinkName"
                                                        placeholder="#{bundle['dataverse.link.yourDataverses.inputPlaceholder']}"
                                                        emptyMessage="#{bundle['dataverse.unlink.dataset.none']}"
                                                        scrollHeight="180" forceSelection="true"
                                                        minQueryLength="1" queryDelay="1000"
                                                        value="#{DatasetPage.selectedDataverseForLinking}"
                                                        multiple="false"
                                                        completeMethod="#{DatasetPage.completeUnLinkingDataverse}"
                                                        required="#{param['DO_DS_LINK_VALIDATION']}" requiredMessage="#{bundle['dataverse.link.select']}"
                                                        styleClass="DropdownPopup" panelStyleClass="DropdownPopupPanel"
                                                        var="dataverseLk" itemLabel="#{dataverseLk.displayName}" itemValue="#{dataverseLk}" converter="dataverseConverter">
                                            <p:column>
                                                <h:outputText value="#{dataverseLk.displayName}"/>
                                            </p:column>
                                            <p:column>
                                                <h:outputText value="#{dataverseLk.alias}"/>
                                            </p:column>
                                            <p:ajax process="@this" event="itemSelect" />
                                            <p:ajax process="@this" event="itemUnselect" />
                                        </p:autoComplete>
                                        <p:message for="dataverseUnLinkName"/>
                                    </p:fragment>
                                </div>
                            </div>
                        </div>
                        <div>
                            <p:fragment rendered="#{empty DatasetPage.alreadyLinkedDataverses}">
                                <h:outputLabel value="#{bundle['dataset.linking.popup.not.linked.note']}"/>&#160;
                                <h:outputText value=""/>
                            </p:fragment>
                        </div>
                        <div class="button-block">
                            <p:commandButton id="deleteLinkButton" styleClass="btn btn-default"
                                             update="linkNameContent @([id$=Messages])"
                                             oncomplete="if (args &amp;&amp; !args.validationFailed) unlinkDatasetCommand();"
                                             value="#{bundle['dataset.unlink.delete']}">
                                <f:param name="DO_DS_LINK_VALIDATION" value="true"/>
                            </p:commandButton>
                            <button class="btn btn-link" onclick="PF('unlinkDatasetForm').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:remoteCommand name="unlinkDatasetCommand" oncomplete="PF('unlinkDatasetForm').hide();" update=":messagePanel  @([id$=Messages])" actionListener="#{DatasetPage.deleteLinkingDataverses}"/>
                    <p:dialog id="computeBatchListPopup" header="#{bundle['dataset.compute.computeBatchListHeader']}" widgetVar="computeBatchListPopup" modal="true">
                        <div class="text-right">
                            <!-- Clear link -->
                            <p:commandButton styleClass="btn btn-default" action="#{DatasetPage.clearCart()}" update=":datasetForm,:messagePanel">
                                <span class="glyphicon glyphicon-remove"/> <h:outputText value="#{bundle['dataset.compute.computeBatchClear']}"/>
                            </p:commandButton>
                        </div>
                        <h:dataTable id="computeBatch" class="table table-striped" value="#{DatasetPage.cartList}" var='computeCartDatasetList'>
                            <h:column>
                                <f:facet name="header">#{bundle.dataset}</f:facet>
                                <h:outputText value="#{computeCartDatasetList.key}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{bundle['dataset.metadata.persistentId']}</f:facet>
                                <h:outputText value="#{computeCartDatasetList.value}"/>
                            </h:column>
                            <h:column>
                                <f:facet name="header">#{bundle['dataset.compute.computeBatchChange']}</f:facet>
                                <p:commandButton value="#{bundle['dataset.compute.computeBatchRemove']}" action="#{DatasetPage.removeCartItem(computeCartDatasetList.key, computeCartDatasetList.value)}" update=":datasetForm,:messagePanel"/>
                            </h:column>
                        </h:dataTable>
                        <div class="button-block">
                            <h:outputLink styleClass="btn btn-default" value="#{DatasetPage.cartComputeUrl}" onclick="PF('computeBatchListPopup').hide()" target="_blank">
                                <h:outputText value="#{bundle['dataset.compute.computeBatchCompute']}"/>
                            </h:outputLink>
                            <button class="btn btn-link" onclick="PF('computeBatchListPopup').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="inreview" header="#{bundle['dataset.submitBtn']}" widgetVar="inreview" modal="true">
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.submitMessage']}
                        </p>
                        <p jsf:rendered="#{!valid}" class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/><b style="color:red;"> #{bundle['dataset.message.incomplete.warning']}</b>
                        </p>
                        <c:if test="#{showSubmitForReviewLink}">
                            <ui:include src="datasetLicenseInfoFragment.xhtml"/>
                        </c:if>
                        <div class="button-block">
                            <p:commandButton rendered="#{DatasetPage.validOrCanReviewIncomplete}" styleClass="btn btn-default" value="#{bundle.submit}" 
                                             onclick="PF('inreview').hide();
                                                     PF('blockDatasetForm').hide();" action="#{DatasetPage.submitDataset}" immediate="true"/>
                            <button class="btn btn-link" onclick="PF('inreview').hide();PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <!-- Publish/Submit for Review Dialogs -->
                    <p:dialog id="publishDataset" width="70%" header="#{bundle['dataset.publish.header']}" widgetVar="publishDataset" modal="true">
                        <ui:fragment rendered="#{publishDataset}">
                            <div class="form-group">
                                <p jsf:rendered="#{valid}" class="col-sm-12 text-warning">#{bundle['dataset.publish.tip']}</p>
                                <p jsf:rendered="#{!valid}" class="col-sm-12 text-warning"><b style="color:red;">#{bundle['dataset.message.incomplete.warning']}</b></p>
                                <p class="col-sm-12 help-block">#{bundle['dataset.publish.terms.tip']}</p>
                            </div>
                        </ui:fragment>
                        <ui:fragment rendered="#{releaseBoth}">
                            <p class="text-warning">
                                <span class="glyphicon glyphicon-warning-sign"/>
                                <h:outputFormat value="#{bundle['dataset.mayNotPublish.both']}" escape="false">
                                    <o:param>
                                        <a href="/dataverse/#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                            <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                        </a>
                                    </o:param>
                                </h:outputFormat>
                            </p>
                        </ui:fragment>
                        <ui:fragment rendered="#{releaseDraft}">
                            <p:focus for="options"/>
                            <p class="text-warning">
                                <span class="glyphicon glyphicon-warning-sign" /> #{bundle['dataset.republish.tip']}
                            </p>
                        </ui:fragment>
                        <ui:fragment rendered="#{releaseBoth}">
                            <div class="form-group">
                                <p class="help-block">
                                    #{bundle['dataset.publishBoth.tip']}
                                </p>
                            </div>
                        </ui:fragment>
                        <div class="well terms-agreement-block" jsf:rendered="#{DatasetPage.displayPublishPopupCustomText}">
                            <h:outputText value="#{DatasetPage.datasetPublishCustomText}" escape="false"/>
                        </div>
                        <ui:fragment rendered="#{releaseDraft}">
                            <ui:fragment rendered="#{DatasetPage.dataset.latestVersion.minorUpdate}">
                                <p class="help-block">
                                    #{bundle['dataset.selectVersionNumber']}
                                </p>
                                <p:selectOneRadio id="options" value="#{DatasetPage.releaseRadio}">
                                    <f:selectItem itemLabel="#{bundle['dataset.minorRelease']} (#{DatasetPage.datasetNextMinorVersion})" itemValue="1" />
                                    <f:selectItem itemLabel="#{bundle['dataset.majorRelease']} (#{DatasetPage.datasetNextMajorVersion})" itemValue="2" />
                                    <c:if test="#{dataverseSession.user.isSuperuser()}">
                                        <f:selectItem rendered="#" itemLabel="#{bundle['dataset.updateRelease']}" itemValue="3" />
                                    </c:if>
                                </p:selectOneRadio>
                            </ui:fragment>
                            <p>
                                <h:outputFormat value="#{bundle['dataset.majorRelease.tip']}" rendered="#{!DatasetPage.dataset.latestVersion.minorUpdate}">
                                    <f:param value="#{DatasetPage.datasetNextMajorVersion}"/>
                                </h:outputFormat>
                            </p>
                        </ui:fragment>
                        <c:if test="#{showPublishLink}">
                            <ui:include src="datasetLicenseInfoFragment.xhtml" />
                        </c:if>
                        <ui:fragment  rendered="#{versionNoteEnabled}">
                            <div class="form-group">
                                <label for="versionNote" class="col-sm-3 control-label">
                                    #{bundle['dataset.version.versionNote.addEdit']}
                                </label>
                                <p:inputTextarea styleClass="col-sm-9" id="versionNote" rows="4" value="#{DatasetPage.publishDialogVersionNote}" title="#{bundle['dataset.version.versionNote.title']}" maxlength="1000" widgetVar="versionNote"
                                             cols="70" counter="display" counterTemplate="{0} characters remaining." autoResize="false"
                                             required="false"/>
                            </div>
                        </ui:fragment>
                        <ui:fragment  rendered="#{publishDataset}">
                            <div class="form-group">
                                <p class="col-sm-12 help-block">#{bundle['dataset.publish.terms.help.tip']}</p>
                            </div>
                        </ui:fragment>
                        <div class="button-block">
                            <p:commandButton rendered="#{valid}" styleClass="btn btn-default" value="#{bundle.continue}" 
                                             onclick="PF('publishDataset').hide();
                                                     PF('blockDatasetForm').hide();" action="#{DatasetPage.releaseDataset}" />
                            <button class="btn btn-link" onclick="PF('publishDataset').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="mayNotRelease" header="#{bundle['dataset.publish.header']}" widgetVar="mayNotRelease" modal="true">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/>
                            <h:outputFormat value="#{bundle['dataset.mayNotPublish.administrator']}" escape="false">
                                <o:param>
                                    <a href="/dataverse.xhtml?alias=#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                    </a>
                                </o:param>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('mayNotRelease').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="maynotPublishParent" header="#{bundle['dataset.publish.header']}" widgetVar="maynotPublishParent" modal="true"  rendered="#{DatasetPage.dataset.owner.owner != null}">
                        <p class="text-danger">
                            <span class="glyphicon glyphicon-exclamation-sign"/>
                            <h:outputFormat value="#{bundle['dataset.mayNotPublish.twoGenerations']}" escape="false">
                                <o:param>
                                    <a href="/dataverse/#{DatasetPage.dataset.owner.alias}" title="#{DatasetPage.dataset.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.displayName}"/>
                                    </a>
                                </o:param>
                                <o:param>
                                    <a href="/dataverse/#{DatasetPage.dataset.owner.owner.alias}" title="#{DatasetPage.dataset.owner.owner.displayName}">
                                        <h:outputText value="#{DatasetPage.dataset.owner.owner.displayName}"/>
                                    </a>
                                </o:param>
                            </h:outputFormat>
                        </p>
                        <div class="button-block">
                            <button class="btn btn-default" onclick="PF('maynotPublishParent').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.close}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="sendBackToContributor" header="#{bundle['dataset.rejectBtn']}" widgetVar="sendBackToContributor" modal="true">
                    <ui:param name="disableReasonField" value="#{FeatureFlags.DISABLE_RETURN_TO_AUTHOR_REASON.enabled()}"/>
                        <p class="text-warning">
                            <span class="glyphicon glyphicon-warning-sign"/> #{bundle['dataset.rejectMessage']} #{disableReasonField ? '':bundle['dataset.rejectMessageReason']}
                        </p>
                        
                        <ui:fragment  rendered="#{!disableReasonField}">
                            <p:inputTextarea id="returnReason" rows="4" value="#{DatasetPage.returnReason}" title="#{bundle['dataset.rejectMessage.label']}" maxlength="2000" widgetVar="returnReason"
                                             cols="70" counter="display" counterTemplate="{0} characters remaining." autoResize="false"
                                             required="#{param['DO_RETURN_TO_AUTHOR_VALIDATION']}"
                                             requiredMessage="#{bundle['dataset.reject.enterReason.error']}"/>
                            <p>
                                <h:outputText id="display"/>
                            </p>
                            <p:watermark for="returnReason" value="#{bundle['dataset.rejectWatermark']}" id="returnReasonWatermark"/>
                            <h:message for="returnReason" styleClass="bg-danger text-danger"/>
                        </ui:fragment>
                        
                        <div class="button-block">
                            <p:commandButton styleClass="btn btn-default" value="#{bundle.continue}"
                                             update="@form"
                                             oncomplete="PF('sendBackToContributor').show();if (args &amp;&amp; !args.validationFailed) returnToAuthorCommand();">
                                <f:param name="DO_RETURN_TO_AUTHOR_VALIDATION" value="true"/>
                            </p:commandButton>
                            <button class="btn btn-link" onclick="PF('sendBackToContributor').hide();
                                    PF('blockDatasetForm').hide();" type="button">
                                #{bundle.cancel}
                            </button>
                        </div>
                    </p:dialog>
                    <p:dialog id="curationStatusHistoryDialog" header="#{bundle['dataset.curationStatusHistory']}"
                            widgetVar="curationStatusHistoryDialog" modal="true" responsive="true">
                        <p:dataTable value="#{version.curationStatuses}" var="status"
                                 styleClass="margin-bottom-half" rowIndexVar="index">
                            <p:column headerText="#{bundle['dataset.curationStatus']}">
                                <h:outputText value="#{status.label}"/>
                            </p:column>
                            <p:column headerText="#{bundle['dataset.curationDate']}">
                                <h:outputText value="#{status.createTime}">
                                    <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="#{TimeZone.default}"/>
                                </h:outputText>
                            </p:column>
                            <p:column headerText="#{bundle['dataset.curationAssigner']}">
                                <h:outputText value="#{status.authenticatedUser.name}"/>
                            </p:column>
                        </p:dataTable>
                    </p:dialog>
                    <p:dialog id="versionNoteId" styleClass="smallPopUp" header="#{bundle['dataset.versionNote.header']}" widgetVar="editVersionNoteDialog" modal="true">
                        <p:fragment id="noteHelpPanel" rendered="#{versionNoteEnabled}">
                            <p class="help-block">
                                <h:outputFormat value="#{bundle['dataset.versionNote.tip']}" escape="false">
                                    <f:param value="#{systemConfig.guidesBaseUrl}"/>
                                    <f:param value="#{systemConfig.guidesVersion}"/>
                                </h:outputFormat>
                            </p>
                            <div class="form-group">
                                <label for="versionNoteInTable" class="col-sm-3 control-label">
                                    #{bundle['dataset.version.versionNote.addEdit']}
                                </label>
                                <p:inputTextarea styleClass="col-sm-9" id="versionNoteInTable" rows="4" value="#{version.versionNote}" title="#{bundle['dataset.version.versionNote.title']}" maxlength="1000" widgetVar="versionNoteInTable"
                                             cols="70" counter="display" counterTemplate="{0} characters remaining." autoResize="false"
                                             required="false"/>
                            </div>
                            <div class="button-block">
                                <p:commandButton rendered="#{valid}" styleClass="btn btn-default" value="#{bundle.saveChanges}"
                                             onclick="PF('editVersionNoteDialog').hide();
                                                     PF('blockDatasetForm').hide();" action="#{DatasetPage.saveVersionNote()}" update=":datasetForm,:messagePanel"/>
                                <button class="btn btn-link" onclick="PF('editVersionNoteDialog').hide();
                                        PF('blockDatasetForm').hide();" type="button">
                                    #{bundle.cancel}
                                </button>
                            </div>
                        </p:fragment>
                    </p:dialog>
                    <ui:fragment rendered="#{empty DatasetPage.editMode}">
                      <script src="https://cdn.jsdelivr.net/npm/citation-js"
                          type="text/javascript"></script>
                      <script>
                          const Cite = require('citation-js');
                          let cite = new Cite(#{version.getCitation("CSL", true, false)});
                      </script>
                      <p:dialog id="cslCitation" header="#{bundle['dataset.cite.cslDialog.title']}"
                          widgetVar="cslCitationDialog" dynamic="true" modal="true">
                        <ui:param name="requestedCSL" value="#{DatasetPage.requestedCSL}"/>
                        <o:importFunctions type="edu.harvard.iq.dataverse.util.CSLUtil" />
                        <o:importFunctions type="de.undercouch.citeproc.CSL" />
                        <o:importFunctions
                            type="edu.harvard.iq.dataverse.pidproviders.PidUtil" />
                        <p:outputLabel for="@next" value="#{bundle['dataset.cite.cslDialog.select']}"/>
                        <p:selectOneMenu value="#{requestedCSL}"
                            onchange="updateCSLCitation()" id="select_CSL_Style"
                            styleClass="form-control"
                            style="width:auto !important; max-width:100%; min-width:200px;"
                            filter="true" filterMatchMode="contains">
                            <f:selectItems value="#{CSLUtil:getSupportedStyles(dataverseSession.localeCode)}"
                                var="cslStyle" itemLabel="#{cslStyle}" itemValue="#{cslStyle}" />
                        </p:selectOneMenu>
                        <p:outputLabel id="cslLabel" for="@next" value="#{bundle['dataset.cite.cslDialog.citation'].replace('{0}', requestedCSL)}"/>
                        <p:outputPanel id="cslOutput">
                            <script>
                                Cite.CSL.register.addTemplate("#{requestedCSL}",
                                        "#{CSLUtil:getCitationFormat((requestedCSL == '') ? 'apa' : requestedCSL)}");
                                
                                document.getElementById('datasetForm:cslOutput').innerHTML = cite.format("bibliography", {
                                    format: "html",
                                    template: "#{requestedCSL}",
                                    lang: "#{dataverseSession.localeCode}"
                                })
                            </script>
                            <h:outputText value="#{bundle['dataset.cite.cslDialog.generating']}"/>
                        </p:outputPanel>
                        <span class="glyphicon glyphicon-copy btn-copy"
                                    data-toggle="tooltip" data-placement="top" data-html="true"
                                    data-clipboard-action="copy"
                                    data-clipboard-target=".csl-entry"
                                    title="#{bundle['dataset.cite.cslDialog.copy']}"></span>
                        <p:commandButton
                            value="#{bundle['file.dataFilesTab.button.direct']}"
                            id="updateCSL" style="display:none" update=":datasetForm:cslOutput, :datasetForm:cslLabel">
                        </p:commandButton>
                        <div class="button-block">
                            <button class="btn btn-link" onclick="PF('cslCitationDialog').hide();"
                                type="button">#{bundle['dataset.cite.cslDialog.close']}</button>
                        </div>
                      </p:dialog>
                    </ui:fragment>
                    <p:remoteCommand name="returnToAuthorCommand" oncomplete="PF('sendBackToContributor').hide();" update=":messagePanel" actionListener="#{DatasetPage.sendBackToContributor}"/>
                    <p:remoteCommand name="linkEditTerms"   actionListener="#{DatasetPage.edit('LICENSE')}" update="@form,:datasetForm,:messagePanel">
                        <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                    </p:remoteCommand>
                    <p:remoteCommand name="editMedatdataCommand"   actionListener="#{DatasetPage.edit('METADATA')}" update="@form,:datasetForm,:messagePanel">
                        <f:setPropertyActionListener target="#{DatasetPage.selectedTabIndex}" value="0" />
                    </p:remoteCommand>
                    <p:remoteCommand name="datasetSaveCommand" action="#{DatasetPage.save()}" update=":datasetForm,:messagePanel"/>
                    <!-- END: Publish/Submit for Review Dialogs -->
                </h:form>
                <c:set var="descriptionText" value="#{DatasetPage.datasetVersionUI.description.datasetFieldType.localeTitle}" />
                <script>
                    //<![CDATA[
                    $(document).ready(function () {
                        popoverHTML('#{bundle.htmlAllowedTitle}', '#{bundle.htmlAllowedTags}');
                        summaryDescTruncation();
                    });
                    function summaryDescTruncation() {
                        // truncate summary description, contentTruncate function in dv_rebind_bootstrap_ui.js
                        // add summary desc row id to pass as selector param
                        var descId = 'dsDescription td > div';
                        // add metadata dynamic label text, tooltip text from bundle as param
                        var truncMoreBtn = '#{of:format1(bundle.truncateMoreBtn, descriptionText)}';
                        var truncMoreTip = '#{of:format1(bundle.truncateMoreTip, descriptionText)}';
                        var truncLessBtn = '#{of:format1(bundle.truncateLessBtn, descriptionText)}';
                        var truncLessTip = '#{of:format1(bundle.truncateLessTip, descriptionText)}';

                        // pass bundle text variabls as params to function
                        contentTruncate(descId, truncMoreBtn, truncMoreTip, truncLessBtn, truncLessTip);
                    }
                    function openDialog() {
                        PF('details').show();
                    }
                    function openCompareTwo() {
                        PF('compareTwo').show();
                    }
                    function editTerms(){  
                        linkEditTerms();
                    }
                    function editMetadata(){                         
                        var validTOA = document.getElementById("datasetForm:validTermsofAccess").value;
                        if (validTOA === 'false'){                            
                            PF('blockDatasetForm').show();
                            PF('accessPopup').show();
                        } else {
                            editMedatdataCommand();
                        }                            
                    }
                    
                    function testCheckBoxes() {
                        var count = PF('versionsTable').getSelectedRowsCount();
                        if (count !== 2) {
                            PF('compareTwo').show();
                        } else {
                            $('button[id$="compareVersions"]').trigger('click');
                        }
                    }
                    function testFilesSelected() {
                        var count = PF('filesTable').getSelectedRowsCount();
                        if (count == 0) {
                            PF('selectFiles').show();
                        } else {
                            return true;
                        }
                    }
                    function testTermsOfAccess() {
                        var valid = document.getElementById("datasetForm:validTermsofAccess").value;
                        if (valid === false) {
                            PF('accessPopup').show();
                            return false;
                        } else {
                            return true;
                        }
                    }
                    function updateTemplate() {
                        $('button[id$="updateTemplate"]').trigger('click');
                    }
                    function updateCSLCitation() {
                        $('button[id$="updateCSL"]').trigger('click');
                    }
                    function updateOwnerDataverse() {
                        $('button[id$="updateOwnerDataverse"]').trigger('click');
                    }
                    
                    function showPopup(isTransfer) {
                        var outcome = document.getElementById("datasetForm:validateFilesOutcome").value;
                        if (outcome ==='Mixed'){
                            if(isTransfer) {
                               PF('globusTransferMixed').show();
                            } else {
                                PF('downloadMixed').show();
                            }
                        }
                        if (outcome ==='FailEmpty'){
                            PF('selectFilesForDownload').show();
                        }
                        if (outcome ==='FailSize'){
                            PF('downloadTooLarge').show();
                        }
                        if (outcome ==='FailRestricted'){
                            if(isTransfer) {
                                PF('transferInvalid').show();
                             } else {
                                PF('downloadInvalid').show();
                             }
                        }
                        if (outcome ==='GuestbookRequired'){
                            PF('guestbookAndTermsPopup').show();
                        }
                    }
                    
                    function testTOADatasetPage() {
                        var termsofAccessHidden, fileAccessRequestHidden;
                        try{
                            termsofAccessHidden = document.getElementById("datasetForm:tabView:termsofAccessHiddenLT").value;
                            fileAccessRequestHidden  = document.getElementById("datasetForm:tabView:fileAccessRequestHiddenLT").value;

                            if ('#{DatasetPage.isHasRestrictedFiles()}' === 'true' && fileAccessRequestHidden === 'false' && termsofAccessHidden === '') {
                                //Not compliant show error keep page open...
                            } else {
                                PF('blockDatasetForm').show();
                                datasetSaveCommand();
                            }
                        }
                        catch (error){
                            //terms not present so save...
                            PF('blockDatasetForm').show();
                            datasetSaveCommand();                        
                        }                         

                    }
                                        
                    //]]>
                </script>
            </ui:define>
        </ui:composition>
    </h:body>
</html>
